Skip to main content

Command Palette

Search for a command to run...

Number of Islands

Published
โ€ข1 min readโ€ขView as Markdown

๐Ÿง  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
1 views

More from this blog

ReStart LeetCode

540 posts