Minimum removal to make palindrome permutation | C # Program to find minimum number of removal to make any permutation of the string a palindrome ; function to find minimum removal of characters ; hash to store frequency of each character ; to set hash array to zeros ; count frequency of each character ; count the odd frequency characters ; if count is - 1 return 0 otherwise return count ; Driver code
using System ; class GFG { static int MAX_CHAR = 26 ; static int minRemoval ( string str ) { int [ ] hash = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) hash [ i ] = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) hash [ str [ i ] - ' a ' ] ++ ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( hash [ i ] % 2 == 1 ) count ++ ; return ( count == 0 ) ? 0 : count - 1 ; } public static void Main ( ) { string str = " geeksforgeeks " ; Console . Write ( minRemoval ( str ) ) ; } }