Answers for "longest palindrome string"

C++
0

Palindrome String

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;
	}
Posted by: Guest on January-08-2022
1

minimum characters to make string palindrome

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];
        }
    }
Posted by: Guest on December-21-2021

Code answers related to "longest palindrome string"

Browse Popular Code Answers by Language