Max Area of Island Problem
Max Area of Island Problem — ExecCode Medium DSA Practice
Solve the Max Area of Island problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given an m×n binary matrix grid. An island is a group of 1's connected 4-directionally. The area of an island is the number of cells with value 1. Return the maximum area of an island. If there is no island, return 0.
Examples
Input grid = [[1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]; Output 6. Input grid = [[0, 0, 0], [0, 0, 0]]; Output 0
Constraints
m == grid.length n == grid[i].length 1 ≤ m, n ≤ 50 grid[i][j] is 0 or 1
Practice Max Area of Island free on ExecCode. Browse DSA problems, topic map, and placement guides.