Check if characters of a given string can be rearranged to form a palindrome | Python3 implementation of above approach . ; bitvector to store the record of which character appear odd and even number of times ; Driver Code
def canFormPalindrome ( s ) : NEW_LINE INDENT bitvector = 0 NEW_LINE for str in s : NEW_LINE INDENT bitvector ^= 1 << ord ( str ) NEW_LINE DEDENT return bitvector == 0 or bitvector & ( bitvector - 1 ) == 0 NEW_LINE DEDENT if canFormPalindrome ( " geeksforgeeks " ) : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT