Number of Islands
๐ง Problem
Given 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.
๐ท๏ธ Tags
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
๐ Difficulty
Medium
โ
Success Rate: 53.8%
๐ฅ Submissions: 2,825,342
๐ Accepted: 1,518,896
โค๏ธ Reactions
๐ Likes: 13254
๐ Dislikes: 320
๐ก Hints
๐ Similar Questions
- Surrounded Regions
- Walls and Gates
- Number of Islands II
- Number of Connected Components in an Undirected Graph
- Number of Distinct Islands
- Max Area of Island
- Count Sub Islands
- Find All Groups of Farmland