BFS2 [leetcode] 733. Flood Fill [leetcode] 733. Flood Fill 문제 풀이 주어진 2차원 배열에서 상하좌우 4방향으로 시작위치의 색과 같은 색이면 새로운 색으로 칠하면 되는 문제이다. dfs, bfs 풀이로 풀면 된다. 처음에 아래와 같이 작성했다가 Time Limit Exceeded 나왔다. class Solution { fun floodFill(image: Array, sr: Int, sc: Int, newColor: Int): Array { val baseColor = image[sr][sc] fun fill(row: Int, col: Int) { if (row !in image.indices || col !in image[0].indices || image[row][col] != baseColor) { retur.. 2021. 10. 3. [leetcode] 111. Minimum Depth of Binary Tree [leetcode] 111. Minimum Depth of Binary Tree 문제 leetcode.com/problems/minimum-depth-of-binary-tree/ Minimum Depth of Binary Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 Root 노드에서 Leaf 노드로 가는 가장 짧은 거리를 찾는 문제이다. 문제자체는 BFS만 알면 풀 수 있는 수준이다.BFS(Breadth-first search) 이용해서 풀었.. 2021. 2. 28. 이전 1 다음