Number Of Island by DFS
Given an m x n
2d grid
map of '1'
s (land) and '0'
s (water), return the number of islands.
An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
์ด๋ฒ ๊ฐ์๋ถํฐ๋ DFS์ BFS๋ฅผ ์ฃผ๋ก ๋ค๋ฃจ๋ ๊ทธ๋ํ ๋ฌธ์ ์ ๊ทผ๋ฐฉ๋ฒ๊ณผ ํ์ด ๋ฐฉ๋ฒ, ์๊ณ ๋ฆฌ์ฆ ๋ฑ์ ๋ํด ์์ธํ ํ์ตํด๋ณผ ๊ฒ์ด๋ค. ์ด๋ ต๊ฒ๋ง ์๊ฐํ์์ง๋ง, ์๊ฐ๋ณด๋ค ๋จ์ํ๊ฒ ์ฌ๊ท ํธ์ถ๋ก ์ฌ๋ฐฉ์ ์๋ ์์์ ๋ฐฉ๋ฌธํ์ฌ ํด๊ฒฐํ๋ค.
Last updated