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 ) : NEW_LINE INDENT len1 += 1 NEW_LINE ans = max ( ans , len1 ) NEW_LINE DEDENT else : NEW_LINE INDENT len1 = 1 NEW_LINE DEDENT return ans NEW_LINE