fork download
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. // palindrone problems
  5. class Solution {
  6. public:
  7. bool isPalindrome(string s) {
  8. // Run the loop for the given problems
  9. for (auto& x : s) {
  10. x = tolower(x);
  11. cout<<s;
  12.  
  13. int n=s.size();
  14. for(int i=0;i<n/2;i++){
  15. // steps to remove the non-alphanumeric characters
  16. if(s[i]<'A'|| s[i]>'Z' && s[i]<'a' || s[i]>'z'){
  17. s.erase(i,1);
  18. i--;
  19. }
  20. if(s[i]==' '){
  21. i++;
  22. }
  23.  
  24. if(s[i]!=s[n-i-1]){
  25.  
  26. return "false";
  27. }
  28.  
  29. }
  30. }
  31. return "true";
  32.  
  33. }
  34. };
  35. int main() {
  36. // your code goes here
  37. Solution s1;
  38. bool Palindrome=s1.isPalindrome("race a car");
  39. cout<<Palindrome;
  40. return 0;
  41. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
race a car1