Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

grid =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Compute area of each island via flood-fill and take the maximum.

Approach

For each land cell, DFS to count connected land, marking visited cells as water. Track the maximum area.

Why it works

Each island’s cells are visited once in a single DFS, producing its exact area.

Code
Loading...
Complexity
Time: O(mn)
Space: O(mn) worst-case recursion/queue
Solution
Updated: 2026-02-23

Idea

Compute area of each island via flood-fill and take the maximum.

Approach

For each land cell, DFS to count connected land, marking visited cells as water. Track the maximum area.

Why it works

Each island’s cells are visited once in a single DFS, producing its exact area.

Code
Loading...
Complexity
Time: O(mn)
Space: O(mn) worst-case recursion/queue