package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev
# README
3341. Find Minimum Time to Reach Last Room I
Solution idea
DFS
dfs(x, y, curTime) :=
it takescurTime
to travel from(0, 0)
to(x, y)
.
Dijkstra
- 矩阵走格子类型题。唯一需要注意的是,下一个格子进入PQ时需要判断: 如果当前时间不够,需要等到moveTime再进入,同时,不管需不需要等待,走到下一格子都需要花费1s. i.e.,
max(curTime, moveTime[dx][dy]) + 1
Time complexity = $O(mn\log{mn})$