1 Star 0 Fork 0

KANLON/algorithm-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
image
interviewOffer
src/com/kanlon
accumulate
add_two_numbers
array
binary_tree_top_to_bottom
blank
common_parentln_tree
continuous_cards
convert_binary_search_tree
copy_complex_list
deletenode
dices_probability
fibonacci
find_max_and_min
first_common_nodes_in_lists
first_not_repeating_char
FirstNotRepeatingChar.java
README.MD
greatest_sum_of_sub_arrays
inverse_pairs
k_least_numbers
kth_node_from_end
last_number_in_circle
listnode
matrix_clockwise
merge_sorted_lists
mirror_tree
more_than_half_number
number_of_1
number_of_k
numbers_appear_once
numof1inbinary
path_in_tree
power
printnumber
queue2stack
reorderarray
reverse_list
reverse_words_in_sentence_and_left_rotate_string
rotate
singleton
sort_array_for_min_number
squence_of_bst
stack_push_pop_order
stack_with_min
string_permutation
string_to_int
sub_tree
totalsort
tree_depth
treenode
two_numbers_or_continues_squence_with_sum
ugly_number
.gitignore
leetcode
other
蓝桥杯
.gitignore
README.MD
剑指Offer 第二版.pdf
剑指Offer 纪念版.pdf
剑指offer 第一版.pdf
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
Loading...
README

面试题35:第一个只出现一次的字符。

题目: 在字符串中找出第一个只出现一次的字符。如输入"abaccdeff",则输出'b'

解题思路

解题思路1(利用自带的hashmap,推荐):

遍历字符,将字符作为key存储在hashmap中,将其出现的次数作为value。第一次遍历字符串时,遇到value为1的,则将其输出或返回,即的第一次出现的字符

解题思路2(自己构造简易hash表):

自己构造hash表,使用字符的ascii码,作为下标,构造256大小的数组,数组的值存放对应元素出现的次数


马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/KANLON/algorithm-demo.git
git@gitee.com:KANLON/algorithm-demo.git
KANLON
algorithm-demo
algorithm-demo
master

搜索帮助