Check if given array can be made 0 with given operations performed any number of times | Function to whether the array can be made zero or not ; Count for even elements ; Count for odd elements ; Traverse the array to count the even and odd ; If arr [ i ] is odd ; If arr [ i ] is even ; Check if count of even is zero or count of odd is zero ; Driver 's Code
function check ( arr , N ) { let even = 0 ; let odd = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( arr [ i ] & 1 ) { odd ++ ; } else { even ++ ; } } if ( even == N odd == N ) document . write ( " " ) ; else document . write ( " " ) ; } let arr = [ 1 , 1 , 3 ] ; let N = arr . length ; check ( arr , N ) ;