Minimum number of Appends needed to make a string palindrome | C # program to find minimum number of appends needed to make a string Palindrome ; Checking if the string is palindrome or not ; single character is always palindrome ; pointing to first character ; pointing to last character ; Recursive function to count number of appends ; Removing first character of string by incrementing base address pointer . ; Driver code
using System ; class GFG { static Boolean isPalindrome ( char [ ] str ) { int len = str . Length ; if ( len == 1 ) return true ; char ptr1 = str [ 0 ] ; char ptr2 = str [ len - 1 ] ; while ( ptr2 > ptr1 ) { if ( ptr1 != ptr2 ) return false ; ptr1 ++ ; ptr2 -- ; } return true ; } static int noOfAppends ( String s ) { if ( isPalindrome ( s . ToCharArray ( ) ) ) return 0 ; s = s . Substring ( 1 ) ; return 1 + noOfAppends ( s ) ; } public static void Main ( String [ ] arr ) { String s = " abede " ; Console . Write ( " { 0 } STRNEWLINE " , noOfAppends ( s ) ) ; } }