You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution : explanation here : https://youtu.be/yhSaL48IHds
solution 1 :
string gameOfThrones(string s) { map<char, int> mp; for(int i = 0; i < s.size(); i++){ if(mp[s[i]] != 0){ mp[s[i]]--; if(mp[s[i]] == 0) mp.erase(s[i]); } else mp[s[i]]++; } if(mp.size() > 1) return "NO"; return "YES"; }
solution 2 :
string gameOfThrones(string s) { map<char, int> mp; for(int i = 0; i < s.size(); i++){ if(mp[s[i]] == 1) mp.erase(s[i]); else mp[s[i]]++; } if(mp.size() > 1) return "NO"; return "YES"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution : explanation here : https://youtu.be/yhSaL48IHds
solution 1 :
solution 2 :