Minimum number of deletions to make a string palindrome | C # program for above approach ; Function to return minimum Element between two values ; Utility function for calculating Minimum element to delete ; Condition to compare characters ; Recursive function call ; Return value , increamenting by 1 ; Function to calculate the minimum Element required to delete for Making string pelindrom ; Utility function call ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int min ( int x , int y ) { return ( x < y ) ? x : y ; } static int utility_fun_for_del ( string str , int i , int j ) { if ( i >= j ) return 0 ; if ( str [ i ] == str [ j ] ) { return utility_fun_for_del ( str , i + 1 , j - 1 ) ; } return 1 + Math . Min ( utility_fun_for_del ( str , i + 1 , j ) , utility_fun_for_del ( str , i , j - 1 ) ) ; } static int min_ele_del ( string str ) { return utility_fun_for_del ( str , 0 , str . Length - 1 ) ; } static void Main ( ) { string str = " abefbac " ; Console . WriteLine ( " Minimum ▁ element ▁ of ▁ " + " deletions ▁ = ▁ " + min_ele_del ( str ) ) ; } }