pocky nè
unknown
c_cpp
2 years ago
462 B
10
Indexable
class Solution {
public:
int firstUniqChar(string s) {
//a = 97, z = 122
int appear[125];
int res = -1; //kết quả trả về
for (int i = 0; i < s.length(); i++) {
appear[(int)s[i]]++;
}
for (int i = 0; i < s.length(); i++)
if (appear[(int)s[i]] == 1)
{
res = i;
break;
}
return res;
}
};Editor is loading...
Leave a Comment