Solution for Minimum appends for palindrome without using LPS array


#1
int Solution::solve(string s) {

    int start=0;
    int f=0;
    int i=0,j=s.length()-1;
    while(i<j){
        if(s[i]==s[j]){
            i++;
            j--;
            f=1;
        }
        else if(f==1){
            start=i;
            j=s.length()-1;
            f=0;
        }
        else{
            i++;
            start=i;
        }
        
    }
    return start;
}