How would you find the number of islands in a grid?
Implement the solution for a rectangular grid containing "1" for land and "0" for water. Return the number of connected land regions, where cells connect only horizontally or vertically, not diagonally. The input is a list of equal-length strings, and the output is an integer.
def num_islands(grid):