You are viewing a single comment's thread. Return to all comments →
My C++ Solution: (gist is: To make a string into palindrome - there should not be multiple characters with odd freq)
string gameOfThrones(string s) { char arr[26] ={0}; bool odd = false; for(int i=0; i<s.size(); i++){ if(arr[s[i]-'a']){ arr[s[i]-'a']--; }else{ arr[s[i]-'a']++; } } for(int i=0; i<26; i++){ if(arr[i]%2 != 0 ){ if( odd == true) return "NO"; else odd = true; } } 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 →
My C++ Solution: (gist is: To make a string into palindrome - there should not be multiple characters with odd freq)