generated from cd155/blind-75-python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
blind-75Blind 75 - Blind-75 problemsBlind 75 - Blind-75 problemsgraphBlind 75 - Graph problemsBlind 75 - Graph problems
Description
LeetCode 200: Number of Islands
Category: Graph
Difficulty: See LeetCode
Solution File: src/graph/number_of_islands.py
Test File: tests/test_number_of_islands.py
Problem Description
Given an m x n 2D binary 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.
Example 1:
Input: grid = [["1","1","1","1","0"],["1","1","0","1","0"],["1","1","0","0","0"],["0","0","0","0","0"]]
Output: 1
Example 2:
Input: grid = [["1","1","0","0","0"],["1","1","0","0","0"],["0","0","1","0","0"],["0","0","0","1","1"]]
Output: 3
Constraints:
- m == grid.length
- n == grid[i].length
- 1 <= m, n <= 300
- grid[i][j] is '0' or '1'
Tasks
- Implement the solution in
src/graph/number_of_islands.py - Ensure all test cases pass
- Analyze time complexity
- Analyze space complexity
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
blind-75Blind 75 - Blind-75 problemsBlind 75 - Blind-75 problemsgraphBlind 75 - Graph problemsBlind 75 - Graph problems