Checking every row for duplicates of a [ i ] [ j ]
for k in range ( m ) : NEW_LINE INDENT if j != k and a [ i ] [ j ] == a [ i ] [ k ] : NEW_LINE INDENT isPresent [ i ] [ j ] = True NEW_LINE isPresent [ i ] [ k ] = True NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE for j in range ( m ) : NEW_LINE