Check if arr [ i ] [ j ] is next to arr [ i ] [ j - 1 ] in every row or not
if ( dp [ j ] [ arr [ 0 ] [ i - 1 ] ] + 1 != dp [ j ] [ arr [ 0 ] [ i ] ] ) : NEW_LINE INDENT check = False NEW_LINE break NEW_LINE DEDENT