A Supermicro SuperBlade monitoring panel represents active components as a 2D grid. Each cell contains "1" for an active component and "0" for an inactive cell. Active cells connected horizontally or vertically belong to the same zone.
Implement num_islands(grid) to return the number of distinct active zones. You may modify grid while processing it.
grid, a list of m rows, where each row is a list of strings containing only "0" and "1". The grid may be empty."1" cells.def num_islands(grid):