If every row has arr [ 0 ] [ j ] next to arr [ 0 ] [ j - 1 ] increment len by 1 and update the value of ans
if ( check ) { len ++ ; ans = Math . max ( ans , len ) ; } else { len = 1 ; } } return ans ; }