Answers for "check if string is palidrome"

C++
1

check if a string is palindrome cpp

// Check whether the string is a palindrome or not.
#include <bits/stdc++.h>

using namespace std;

int main(){
    string s;
    cin >> s;
    
    int l = 0;
    int h = s.length()-1;

    while(h > l){
        if(s[l++] != s[h--]){
            cout << "Not a palindrome" << endl;
            return 0;
        }
    }
    cout << "Is a palindrome" << endl;
    return 0;

}
Posted by: Guest on January-23-2021
-1

check if palindrome

function isPalindrome(str) {
  str = str.toLowerCase();
  return str === str.split("").reverse().join("");
}
Posted by: Guest on August-17-2020

Browse Popular Code Answers by Language