20. Non Repeating Character
My Approach
Time and Auxiliary Space Complexity
Code (C++)
class Solution {
public:
char nonrepeatingCharacter(string S) {
int cnt[26] = {0};
for (auto ch : S) {
cnt[ch - 'a']++;
}
for (auto ch : S) {
if (cnt[ch - 'a'] == 1) {
return ch;
}
}
return '$';
}
};Contribution and Support
Last updated