摘要:
problem:https://leetcode.com/problems/shortest-path-in-binary-matrix/ 非常基础的单源无权最短路径,没有任何变化。 阅读全文
posted @ 2019-08-06 22:03
fish1996
阅读(258)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/shortest-path-with-alternating-colors/ 周赛题,这道题是带约束的最短路径,我的做法是对不同颜色节点维护两个容器,分别计算从红色结点开始和从蓝色结点开始,取其中最小的。(这道题没有必要用优 阅读全文
posted @ 2019-08-06 20:08
fish1996
阅读(306)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/sliding-puzzle/ 一看到求最短次数就是宽搜了。用字符串来记录所有状态量即可,找到目标状态量后就退出,我们总能保证找到时用到的步数是最少的。 阅读全文
posted @ 2019-08-06 15:58
fish1996
阅读(125)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/snakes-and-ladders/ 这道题需要换算位置和数字之间的关系,虽然并不难但是很繁琐。 因为遇到了梯子/蛇一定要滑过去,所以我们可以当作把这一位置作为跳板直接到达了梯子末端,就好像没有来过这一位置一样。 阅读全文
posted @ 2019-08-06 14:39
fish1996
阅读(197)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/longest-consecutive-sequence/ 使用并查集,时间不是严格的O(n) 阅读全文
posted @ 2019-08-06 12:44
fish1996
阅读(225)
评论(0)
推荐(0)

浙公网安备 33010602011771号