Guest User

Untitled

a guest
Nov 17th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. //A Better solution thanks to the pre-sorting (Transform & Conquer)
  2. //Time complexity depends on the sorting algorithm complexity: in this case O(nlog(n))
  3. #include <iostream>
  4. #include <string>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. int main(int argc, char const *argv[]) {
  9. string a;
  10. int counter=1;
  11. cin >> a;
  12. sort(a.begin(),a.end()); // Sorting the string !!
  13. for (size_t i = 1; i < a.length(); i++) {
  14. if (a[i]!=a[i-1]) { //if a letter is not equal to its predecessor
  15. counter++; //then it's not counted before so Count it !!
  16. }
  17. }
  18. if (counter%2==0) {
  19. cout << "CHAT WITH HER!";
  20. }
  21. else cout << "IGNORE HIM!";
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment