Product
Pricing
Blog
Forum
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
AI Insights
Quick Summary
Identify all connected land components in a 2D binary grid.
Calculate both the total land cells and distinct adjacent water cells for each component.
Return a collection of [area, boundary_count] pairs without caring about order.
What This Tests
Grid-based graph traversal
Connected component analysis
State tracking and cycle prevention
Using hash sets for unique element counting
Common Patterns
DFS/BFS
Graph Traversal
Hashing
Collapse
Hint 1
Hint 2
What Interviewers May Ask Next
Report
Report seen similar question in interview
Accepted
2k
/3.6k
Acceptance Rate
55.3%
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
Python3
Auto
Debug
Run
Submit
Test Cases
Input
grid =
Output
Expected