-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_of_thrones.cpp
More file actions
45 lines (35 loc) · 784 Bytes
/
game_of_thrones.cpp
File metadata and controls
45 lines (35 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <bits/stdc++.h>
using namespace std;
/*
* Complete the 'gameOfThrones' function below.
*
* The function is expected to return a STRING.
* The function accepts STRING s as parameter.
*/
string gameOfThrones(string s) {
sort(s.begin(), s.end());
int count1 = 1, count2 = 0;
for(int i = 0; i < s.size(); i++) {
if(s[i] == s[i+1]) {
count1++;
} else {
if(count1 % 2 != 0) {
count2++;
}
count1 = 1;
}
}
if(count2 > 1)
return "NO";
return "YES";
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string s;
getline(cin, s);
string result = gameOfThrones(s);
fout << result << "\n";
fout.close();
return 0;
}