Horje
Palindrome String Code Example
check if a string is a palindrome
int length = myString.Length;
for (int i = 0; i < length / 2; i++)
{
    if (myString[i] != myString[length - i - 1])
        return false;
}
return true;
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];
        }
    }
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;
	}
check if palindrome
function isPalindrome(str) {
  str = str.toLowerCase();
  return str === str.split("").reverse().join("");
}




Cpp

Related
vector size for loop Code Example vector size for loop Code Example
compare values within within a vector c++ Code Example compare values within within a vector c++ Code Example
cpp template Code Example cpp template Code Example
string to vector char c++ Code Example string to vector char c++ Code Example
c++ write to file in directory Code Example c++ write to file in directory Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9