class Solution {
public:
char firstUniqChar(string s) {
//unordered_map<char, int> freq;
int freq[256]= {0};
for(char ele: s)
freq[ele]++;
for(char ele: s)
if(freq[ele]== 1)
return ele;
return ' ';
}
};
【剑指offer】面试题50:第一个只出现一次的字符——哈希表查找
最新推荐文章于 2022-04-03 19:11:37 发布