Created
July 1, 2015 16:46
-
-
Save andijcr/780ce9a67462299ec4ec to your computer and use it in GitHub Desktop.
anagram palindrome test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(){ | |
vector<int> char_count(int('z'-'a')+1); | |
string word; | |
cin >> word; | |
for_each(begin(word), end(word), [&char_count](char c){ char_count[int(c-'a')]++; }); | |
auto odd=count_if(begin(char_count), end(char_count), [](int count){ return (count%2) == 1;}); | |
if(word.length()%2 == 1) --odd; | |
cout << (odd==0)? "YES" : "NO"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment