LeetCode - Max Area of Island (Javascript)

Description
위에서 풀었던 문제와 굉장히 유사하다. 그냥 그 문제에서 최대 넓이만 구하면 되는 문제다!
You are given an m x n binary matrix grid. An island is a group of 1‘s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
The area of an island is the number of cells with a value 1 in the island.
Return the maximum area of an island in grid. If there is no island, return 0.
Example 1:

1 | Input: grid = [[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,0,0,1,0,1,0,0],[0,1,0,0,1,1,0,0,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,0,1,1,0,0,0,0]] |
Example 2:
1 | Input: grid = [[0,0,0,0,0,0,0,0]] |
Constraints:
m == grid.lengthn == grid[i].length1 <= m, n <= 50grid[i][j]is either0or1.
소스 코드
1 | function maxAreaOfIsland(grid) { |
LeetCode - Max Area of Island (Javascript)
https://hoonjoo-park.github.io/algorithm/leet/maxAreaOfIslands/