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
function check ( Arr , n , M , K ) { let flag = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( Arr [ i ] == 0 ) flag = 1 ; } if ( K % 2 != 0 && flag == 0 ) return " " ; else return " " ; } let Arr = [ 1 , 1 , 2 , 4 , 7 , 8 ] ; let M = 5 ; let K = 6 ; let n = Arr . length ; document . write ( check ( Arr , n , M , K ) ) ;