Array to note down frequency of each set
int * c = new int [ n * m ] ; int numberOfIslands = 0 ; for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < m ; k ++ ) { if ( a [ j ] [ k ] == 1 ) { int x = dus -> find ( j * m + k ) ;