ronith
11/1/2018 - 3:50 AM

Minimum number of Appends needed to make a string palindrome

//https://www.geeksforgeeks.org/minimum-number-appends-needed-make-string-palindrome/
#include <bits/stdc++.h>
using namespace std;

bool isPalin (char *s) {
    int n= strlen(s);
    if (n== 1)
        return 1;
    char *p1= s;
    char *p2= s+n-1;
    while (p1<p2) {
        if (*p1!= *p2)
            return 0;
        p1++;
        p2--;
    }
    return 1;
}

int func (char s[]) {
    if (isPalin(s))
        return 0;
    s++;
    return 1+func(s);
}


int main() {
    char s[]= "aabb";

    cout<< func(s);
}