Driver Code
let arr = [ 1 , 0 , 2 , 2 , 5 , 5 , 5 ] ; let N = arr . length ; let K = 1 ; let length = longestSubarray ( arr , N , K ) ; if ( length == 1 ) document . write ( - 1 ) ; else document . write ( length ) ;