200. Number of Islands
·
Algorithm/LeetCode
문제전형적인 bfs 탐색 문제였다. 0은 물, 1은 땅을 의미하는 그래프 배열이 주어진다. 땅이 근접하게 모여 있으면 하나의 섬이다. 섬의 갯수를 요구하는 문제였다.링크: https://leetcode.com/problems/number-of-islands/description/Solutionclass Solution { static int[][] dirArray = {{-1,0},{1,0},{0,-1},{0,1}}; public int numIslands(char[][] grid) { int m = grid.length; int n = grid[0].length; boolean[][]visited = new boolean[m][n]; int ..