(This question is a variation of the LeetCode question Number of Islands. If you haven't completed that question yet, it is recommended to solve it first.)
You are given a m × n 2D grid where each cell contains either a positive integer or 0. A cell with a positive integer represents part of an island, while a cell with 0 is water.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected