Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- unsigned int chars[26];
- // Complete the gameOfThrones function below.
- string gameOfThrones(string s) {
- bool jo = true;
- for(int i=0;i<s.length();i++){
- chars[s[i]-'a']++;
- }
- if(s.length()%2==0)
- {
- for(int i=0;i<26 && jo; i++){
- if(chars[i]%2!=0)
- jo = false;
- }
- }
- else
- {
- bool voltPrtln = false;
- for(int i=0; i<26; i++)
- {
- if(chars[i]%2!=0)
- {
- if(!voltPrtln)
- {
- voltPrtln=true;
- }
- else
- {
- jo=false;
- }
- }
- }
- }
- return jo ? "YES" : "NO";
- }
- int main()
- {
- ofstream fout(getenv("OUTPUT_PATH"));
- string s;
- getline(cin, s);
- string result = gameOfThrones(s);
- fout << result << "\n";
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement