695. Max Area of Island

Practice Max Area of Island for free on NudgeCode: Medium, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

The grid is a map where 1 is land and 0 is water. An island is a group of land cells connected up, down, left or right. The area of an island is the number of cells in it. Return the largest island area, or 0 if there is no land.

Example

grid = [[1,1,0,0,0],
        [1,1,0,0,0],
        [0,0,0,1,1],
        [0,0,0,1,1],
        [0,0,0,0,1]]  ->  5

Constraints