fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. std::string s = "Have you seen the new Ssang Yong?";
  9.  
  10. auto comparator = [](const char left, const char right) {
  11. bool isEqual = std::tolower(left) == std::tolower(right);
  12. bool isLeftConverted = left == std::tolower(left);
  13. bool isRightConverted = right == std::tolower(right);
  14. return isEqual && (isLeftConverted ^ isRightConverted);
  15. };
  16.  
  17. for (auto it = std::adjacent_find(s.begin(), s.end(), comparator);
  18. it != s.end();
  19. it = adjacent_find(it, s.end(), comparator))
  20. {
  21. it = s.erase(it, std::next(it, 2));
  22.  
  23. }
  24. std::cout << s;
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5504KB
stdin
Standard input is empty
stdout
Have you seen the new ang Yong?