Number of Distinct Islands
Medium · Graphs · about 25 minutes
Asked at Amazon, ByteDance, Snap, Microsoft, Oracle, IBM.
Given a binary grid (1 = land), count the islands with distinct shapes. Two islands have the same shape if one can be translated onto the other (no rotation or reflection).