리트코드
-
[LeetCode] 773. Flood Fill알고리즘 2022. 5. 26. 23:23
[LeetCode] 773. Flood Fill DFS 로 풀 수 있는 문제이다. 나의 풀이 class Solution: def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]: n = len(image) m = len(image[0]) visited = [[0] * m for _ in range(n)]; dx = [1,-1,0,0] dy = [0,0,1,-1] def dfs(r,c, targetColor, newColor): for _ in range(4): newR = r + dy[_] newC = c + dx[_] if (newR = n or newC < 0 o..