class Solution { public: int FirstNotRepeatingChar(string str) { map<char,int> mp; int i=0; for(char k : str) mp[k]++; for(char k : str){ i++; if(mp[k]==1) return i-1; } return -1; } };
class Solution { public: int FirstNotRepeatingChar(string str) { map<char,int> mp; int i=0; for(char k : str) mp[k]++; for(char k : str){ i++; if(mp[k]==1) return i-1; } return -1; } };