Repeating Sub-Sequence Time : Space : 12345678910111213141516171819int Solution::anytwo(string A) { unordered_map<char, vector<int>> mp; for(int i = 0; i < A.length(); i++) mp[A[i]].push_back(i); for(char a = 'a'; a <= 'z'; a++) { for(char b = 'a'; b <= 'z'; b++) { if(mp[a].size() < 2) continue; if(mp[b].size() < 2) continue; if(a == b) { if(mp[a].size() >= 3) return true; } else { auto& A = mp[a]; auto& B = mp[b]; if(A[0] < B[B.size() - 2] and A[1] < B[B.size() - 1]) return true; } } } return 0;}