Input: S = "abba"Output: 1Explanation: S is a palindrome
int isPalindrome(string S)
{
string st = S;
char temp;
int i=0, j= st.length()-1;
while(j>i)
{
if(S[i] != S[j])
{
return 0;
}
i++;
j--;
}
return 1;
}
const isPalindrome = (str) => {
const preprocessing_regex = /[^a-zA-Z0-9]/g,
processed_string = str.toLowerCase().replace(preprocessing_regex , ""),
integrity_check = processed_string.split("").reverse().join("");
if(processed_string === integrity_check) return true
else return false
}
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
string s;
int len=0,i=1;
cin>>s;
int n=s.size();
vector<int> LPS(n);
LPS[0]=0;
while(i<n)
{
if(s[i]==s[len]) LPS[i++]=++len;
else
{
if(len==0) LPS[i++]=0;
else len=LPS[len-1];
}
}
int isPlaindrome(string S)
{
// Your code goes here
int flag =0;
int l=0;
int h=S.length()-1;
while(h>l){
if(S[l++]!=S[h--]){
return 0;
}
}
return 1;
}
Input: S = "abc" Output: 0Explanation: S is not a palindrome