How do you check if a given String is Palindrome or not? code example
Example 1: check if palindrome
function isPalindrome(str) {
str = str.toLowerCase();
return str === str.split("").reverse().join("");
}
Example 2: check palindrome
bool isPlaindrome(string s)
{
int i=0;
int j=s.length()-1;
while(i<j)
{
if(s[i]==s[j])
{i++;
j--;}
else break;
}
if (i==j || i>j) return 1;
else return 0;
}