strings/081_min char to make palindrome.cpp
vector<int> computeLPSArray(string str)
{
    int M = str.length();
    vector<int> lps(M);
 
    int len = 0;
    lps[0] = 0; // lps[0] is always 0
 
    // the loop calculates lps[i] for i = 1 to M-1
    int i = 1;
    while (i < M)
    {
        if (str[i] == str[len])
        {
            len++;
            lps[i] = len;
            i++;
        }
        else // (str[i] != str[len])
        {
            // This is tricky. Consider the example.
            // AAACAAAA and i = 7. The idea is similar
            // to search step.
            if (len != 0)
            {
                len = lps[len-1];
 
                // Also, note that we do not increment
                // i here
            }
            else // if (len == 0)
            {
                lps[i] = 0;
                i++;
            }
        }
    }
    return lps;
}
// returns vector lps for given string str

returns vector lps for given string str
returns vector lps for given string str
vector<int> computeLPSArray(string str)
{
    int M = str.length();
    vector<int> lps(M);
    int len = 0;
    lps[0] = 0; 
    int i = 1;
    while (i < M)
    {
        if (str[i] == str[len])
        {
            len++;
            lps[i] = len;
            i++;
        }
        else 
        {
            if (len != 0)
            {
                len = lps[len-1];
            }
            else 
            {
                lps[i] = 0;
                i++;
            }
        }
    }
    return lps;
}
vector < int > computeLPSArray ( string str ) { int M = str . length ( ) ; vector < int > lps ( M ) ; int len = 0 ; lps [ 0 ] = 0 ; int i = 1 ; while ( i < M ) { if ( str [ i ] == str [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } return lps ; }
returns vector lps for given string str
returns vector lps for given string str
// lps[0] is always 0
 // the loop calculates lps[i] for i = 1 to M-1
 // (str[i] != str[len])
 // This is tricky. Consider the example.
 // AAACAAAA and i = 7. The idea is similar
 // to search step.
 // Also, note that we do not increment
 // i here
 // if (len == 0)
