Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A Better solution thanks to the pre-sorting (Transform & Conquer)
- //Time complexity depends on the sorting algorithm complexity: in this case O(nlog(n))
- #include <iostream>
- #include <string>
- #include <algorithm>
- using namespace std;
- int main(int argc, char const *argv[]) {
- string a;
- int counter=1;
- cin >> a;
- sort(a.begin(),a.end()); // Sorting the string !!
- for (size_t i = 1; i < a.length(); i++) {
- if (a[i]!=a[i-1]) { //if a letter is not equal to its predecessor
- counter++; //then it's not counted before so Count it !!
- }
- }
- if (counter%2==0) {
- cout << "CHAT WITH HER!";
- }
- else cout << "IGNORE HIM!";
- return 0;
- }
Add Comment
Please, Sign In to add comment