0% completed
Problem Statement
You are given a 2D matrix containing only 1s (land) and 0s (water).
An island is a connected set of 1s (land) and is surrounded by either an edge or 0s (water). Each cell is considered connected to other cells horizontally or vertically (not diagonally).
Two islands are considered the same if and only if they can be translated (not rotated or reflected) to equal each other.
Write a function to find the number of distinct islands in the given matrix.
Example 1
Input: matrix =

Output: 2
Explanation: There are four islands in the given matrix, but three of them are the same; hence, there are only two distinct islands.
Example 2
Input: matrix =

Output: 2
Explanation: There are three islands in the given matrix, but two of them are the same; hence, there are only two distinct islands.
Try it yourself
Try solving this question here:
.....
.....
.....
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible