Given a binary grid where 1 represents land and 0 represents water, return the area of the largest island — a group of 1s connected horizontally or vertically. Return 0 if there is no island.
grid with one connected region of six 1s6Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →A graph models relationships as nodes and edges, which can be directed or undirected, weighted or not. Most graph problems come down to choosing the right traversal — DFS, BFS, or union-find — for what you're trying to find.
Original problem on LeetCode ↗