Check if original Array is retained after performing XOR with M exactly K times | Function to check if original Array can be retained by performing XOR with M exactly K times ; Check if O is present or not ; If K is odd and 0 is not present then the answer will always be No . ; Else it will be Yes ; Driver Code
def check ( Arr , n , M , K ) : NEW_LINE INDENT flag = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( Arr [ i ] == 0 ) : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT DEDENT if ( K % 2 != 0 and flag == 0 ) : NEW_LINE INDENT return " No " NEW_LINE DEDENT else : NEW_LINE INDENT return " Yes " ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT Arr = [ 1 , 1 , 2 , 4 , 7 , 8 ] NEW_LINE M = 5 ; NEW_LINE K = 6 ; NEW_LINE n = len ( Arr ) ; NEW_LINE print ( check ( Arr , n , M , K ) ) NEW_LINE DEDENT