fork download
  1. #include <iostream>
  2. using namespace std;
  3. // problems for the Palindrone problems
  4. class Solution {
  5. public:
  6. bool isPalindrome(string s) {
  7. int l=0;
  8. int h=s.size()-1;
  9. // Run the loop for the given problems
  10. for(int i=0;i<=h;i++){
  11. s[i]=tolower(s[i]);
  12.  
  13. // compare the character untill they are equal
  14. while(l<=h){
  15. if(!(s[l]>='a' && s[l]<='z')){
  16. l++;
  17. }
  18. if(!(s[h]>='a' && s[h]<='z')){
  19. h--;
  20. }
  21. else if(s[l]==s[h]){
  22. l++, h--;
  23. }
  24. else{
  25. return false;
  26. }
  27.  
  28. }
  29. }
  30. // return true if the statement is palindrone
  31. return true;
  32.  
  33. }
  34. };
  35.  
  36. int main() {
  37. // your code goes here
  38. Solution s1;
  39. bool Palindrome=s1.isPalindrome("A man, a plan, a canal: Panama");
  40. cout<<Palindrome;
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0.01s 5264KB
stdin
Standard input is empty
stdout
Standard output is empty