Making zero array by decrementing pairs of adjacent | Javascript implementation of the above approach ; Converting array element into number ; Check if divisible by 11 ; Driver code
function isPossibleToZero ( a , n ) { let num = 0 ; for ( let i = 0 ; i < n ; i ++ ) num = num * 10 + a [ i ] ; return ( num % 11 == 0 ) ; } let arr = [ 0 , 1 , 1 , 0 ] ; let n = arr . length ; if ( isPossibleToZero ( arr , n ) ) document . write ( " " ) ; else document . write ( " " ) ;