Question
Given a rectangular grid of characters, where `'1'` is land and `'0'` is water, return the number of edge-connected land components. Diagonal cells are not connected. ```python def count_islands(grid: list[list[str]]) -> int: ... ``` The grid may be empty. You may either mutate the grid or maintain separate visited state, but state your choice. Target `O(rows * columns)` time. ## Staged follow-ups 1. Return the area of the largest island. 2. Count islands as land cells are added incrementally. 3. Process a grid too large to hold fully in memory, one row at a time.