Number Of Distinct Island

Given an m*n binary matrix mat, return the number of distinct island.

An island is considered to be the same as another if and only if one island can be translated (and not rotated or reflected) to equal the other.
Input Format
First line contains two integers n and m.
Each of next n lines contain n numbers containing either 0 or 1.
Output Format
print number of distinct island.
Question Video
1<= n <= 1000
1<= e <= n*(n-1)/2
Sample Input
3 3
1 0 0
0 1 0
1 1 1
Sample Output

  • Asked in Companies
  • Related Topics

Video Solution

Code Solution

Id Name