Minimum removal to make palindrome permutation | 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 0 , return 0 otherwise return count ; Driver 's Code
def minRemoval ( strr ) : NEW_LINE INDENT hash = [ 0 ] * 26 NEW_LINE for char in strr : NEW_LINE INDENT hash [ ord ( char ) - ord ( ' a ' ) ] = hash [ ord ( char ) - ord ( ' a ' ) ] + 1 NEW_LINE DEDENT count = 0 NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT if hash [ i ] % 2 : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT DEDENT return 0 if count == 0 else count - 1 NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT strr = " geeksforgeeks " ; NEW_LINE DEDENT