Coding Round 2
Mid
programming
**LeetCode #200 - Number of Islands** \nBackground: Given a 2D grid of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are surrounded by water. \nProblem Statement: Implement a function `int numIslands(char[][] grid)` that returns the number of islands in the given grid. \nExample 1: \nInput: grid = [ ['1','1','1','1','0'], ['1','1','0','1','0'], ['1','1','0','0','0'], ['0','0','0','0','0'] ] \nOutput: 1 \nExample 2: \nInput: grid = [ ['1','1','0','0','0'], ['1','1','0','0','0'], ['0','0','1','0','0'], ['0','0','0','1','1'] ] \nOutput: 3 \nConstraints: `m == grid.length`, `n == grid[i].length`, `1 <= m, n <= 300`.
Suggested Answer