两种解法的思路都是一样的,只是实现过程不一样。
第一种是我们用数组来记录出现的次数,第二种直接是用map。
class Solution {
public:
int FirstNotRepeatingChar(string str) {
int* a = new int[60];
for(auto ch:str)
{
a[ch-'A']+=1;
}
for(int i = 0;i
map
class Solution {
public:
int FirstNotRepeatingChar(string str) {
map m;
for(auto ch:str)
{
m[ch]++;
}
for(int i = 0;i