⚡️ Tryprepforge
Coding Round 2 Junior programming

**LeetCode #200 - Number of Islands**\nGiven an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return 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 all surrounded by water.\n\n### Example 1:\n**Input:** grid = [[1,1,0,0,0],[1,1,0,0,0],[0,0,0,1,1],[0,0,0,1,1]]\n**Output:** 2\n**Explanation:** There are two islands in the grid.\n\n### Example 2:\n**Input:** grid = [[1,1,1,1,0],[0,1,0,0,0],[0,0,0,0,0],[0,0,1,1,1]]\n**Output:** 1\n**Explanation:** There is only one island in the grid.\n\n### Constraints:\n* m == grid.length\n* n == grid[i].length\n* 1 <= m, n <= 300\n* grid[i][j] is '0' or '1'.

Suggested Answer

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

No credit card required

More Coding Round 2 Interview Prep

Link copied to clipboard