Driver Code
int main ( ) { int arr [ ] = { 1 , 0 , 2 , 2 , 5 , 5 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 1 ; int length = longestSubarray ( arr , N , K ) ; if ( length == 1 ) cout << -1 ; else cout << length ; return 0 ; }