LeetCode - Number of Closed Islands (Javascript)
Description
1이라는 물에 둘러싸인 0이라는 섬의 개수를 구하는 문제다.
Given a 2D grid
consists of 0s
(land) and 1s
(water). An island is a maximal 4-directionally connected group of 0s
and a closed island is an island totally (all left, top, right, bottom) surrounded by 1s.
Return the number of closed islands.
Example
Example 1:
1 | Input: grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0],[1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0]] |
Example 2:
1 | Input: grid = [[0,0,1,0,0],[0,1,0,1,0],[0,1,1,1,0]] |
Example 3:
1 | Input: grid = [[1,1,1,1,1,1,1], |
소스코드
1 | function closedIsland(grid) { |
소스코드 (주석 제거)
1 | function closedIsland(grid) { |
LeetCode - Number of Closed Islands (Javascript)
https://hoonjoo-park.github.io/algorithm/leet/numberOfClosedIslands/