Your question is Island Problem Traversal. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Solve the island counting problem on a grid using connected-component traversal.
Implement num_islands(grid), where grid is a rectangular list of lists containing only the strings "1" and "0". Return the number of connected components of "1" cells, considering only up, down, left, and right neighbors. The function may use an iterative traversal and may modify the input grid.
def num_islands(grid):