⚡️ Tryprepforge
Backend Engineering Senior programming

LeetCode #200 - Number of Islands: 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 all surrounded by water. ### Input - A 2D grid represented as a list of lists. ### Output - An integer representing the number of islands. ### Example Input: [[1,1,0,0,0], [1,1,0,0,0], [0,0,1,0,0], [0,0,0,1,1]] Output: 3 ### Constraints - 0 <= grid.length, grid[i].length <= 300

Suggested Answer

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code formatting, and immersive audio explanations.

No credit card required

More Backend Engineering Interview Prep

Link copied to clipboard