Count distinct possible Bitwise XOR values of subsets of an array | Stores the mask of the vector ; Stores the current 20 of dp [ ] ; Function to store the mask of given integer ; Iterate over the range [ 0 , 20 ] ; If i - th bit 0 ; If dp [ i ] is zero ; Store the position in dp ; Increment the answer ; Return from the loop ; mask = mask XOR dp [ i ] ; Function to find the 20 of the set having Bitwise XOR of all the subset of the given array ; Traverse the array ; Prthe answer ; Driver Code ; Function Call
dp = [ 0 ] * 20 NEW_LINE ans = 0 NEW_LINE def insertVector ( mask ) : NEW_LINE INDENT global dp , ans NEW_LINE for i in range ( 20 ) : NEW_LINE INDENT if ( ( mask & 1 << i ) == 0 ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( not dp [ i ] ) : NEW_LINE INDENT dp [ i ] = mask NEW_LINE ans += 1 NEW_LINE return NEW_LINE DEDENT mask ^= dp [ i ] NEW_LINE DEDENT DEDENT def maxSizeSet ( arr , N ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT insertVector ( arr [ i ] ) NEW_LINE DEDENT print ( ( 1 << ans ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 , 5 ] NEW_LINE N = len ( arr ) NEW_LINE maxSizeSet ( arr , N ) NEW_LINE DEDENT