Skip to content

Instantly share code, notes, and snippets.

@andijcr
Created July 1, 2015 16:46
Show Gist options
  • Save andijcr/780ce9a67462299ec4ec to your computer and use it in GitHub Desktop.
Save andijcr/780ce9a67462299ec4ec to your computer and use it in GitHub Desktop.
anagram palindrome test
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