Count Islands per Distinct Number
Asked at Amazon · Coding Questions · Difficulty: Medium
Given a grid of non-negative integers (`0` is water), for each distinct non-zero number count how many islands (4-directionally connected regions of that same number) it forms. Return a dict mapping each number to its island count.
Loading the problem…