class Solution { public: int firstUniqChar(string s) { int len = s.length(); std::unordered_map map1; // traverse the string and count the frequence of each character. for(int i=0;i myQueue; for(int i=0;i1){ myQueue.pop(); index++; }else{ // found the non-repeating character break; } } // if not found, return -1. if(index>=len){ return -1; } return index; } };