luiz
Đã tốn tiền
Nhìn condition vài toán 10^5 mà cũng chơi DFS đc à @@Mã:class Solution: def minimumObstacles(self, grid: List[List[int]]) -> int: rows = len(grid) cols = len(grid[0]) heap = [(0, (0, 0))] visited = set() while heap: obs, (r, c) = heapq.heappop(heap) if (r, c) == (rows - 1, cols - 1): return obs + grid[r][c] if (r, c) in visited: continue visited.add((r, c)) for rd, cd in [(r - 1, c), (r + 1, c), (r, c - 1), (r, c + 1)]: if 0 <= rd < rows and 0 <= cd < cols and (rd, cd) not in visited: heapq.heappush(heap, (obs + grid[rd][cd], (rd, cd))) return rows + cols - 1
Lúc đầu ngồi chạy DFS ngu người![]()


nhột quá nha

, beat được 100%