⚡️ Tryprepforge
Coding Round 2 Mid-Level programming

LeetCode #200 - Number of Islands\nGiven 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 all surrounded by water.\n\n### Problem Statement\n```python\ndef num_islands(grid: List[List[str]]) -> int:\n```\n### Example 1\n**Input:** ["11110", "11010", "11000", "00000"] \n**Output:** 1 \n**Explanation:** There is one island.\n\n### Example 2\n**Input:** ["11000", "11000", "00100", "00011"] \n**Output:** 3 \n**Explanation:** There are three islands.\n\n### Constraints\n* 1 <= grid.length, grid[0].length <= 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