https://leetcode.com/problems/number-of-islands/description/
Asked in the DSA stage. One of 3 DSA coding problems asked in this round.
Given a 2D grid containing "1" for land and "0" for water, return the number of islands. An island is a group of horizontally or vertically adjacent land cells surrounded by water or the grid boundary.
Implement num_islands(grid). You may modify grid while traversing it.
grid is a list of nonempty lists of strings with equal lengths. Return an integer.
def num_islands(grid):