Array to note down frequency of each set
c = [ 0 ] * ( n * m ) NEW_LINE numberOfIslands = 0 NEW_LINE for j in range ( n ) : NEW_LINE INDENT for k in range ( n ) : NEW_LINE INDENT if a [ j ] [ k ] == 1 : NEW_LINE INDENT x = dus . find ( j * m + k ) NEW_LINE DEDENT DEDENT DEDENT