Skip to main content

Max Area of Island

Given a binary grid where 1=land and 0=water Islands are groups of 1's connected 4-directionally Return the maximum area (number of cells) of any island, or 0 if no islands Example: [[0,0,1,0],[0,1,1,0],[1,1,0,0]] => 4

Max Area of Island is a traversal problem: the hard part is modeling the state you visit. Interviewers love it because it reveals your traversal modeling and your edge-case discipline. Be clear about what a state is; that's the difference between BFS/DFS working or blowing up.

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit, and to talk with her for one hour. After that, talking comes with the $79 pack. Anyone can open the editor and run their code.

1Find Maximum Island Areamedium
Based onLeetCode

Get a note when something new lands

New company guides, new problems and big changes to Coco. Rare, and you can leave any time. By joining you agree to get these emails.