![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
StevenCooks
这个作者很懒,什么都没留下…
展开
-
[Leetcode] 126 Word Ladder II 解题 (和127的对比)
Loading...https://leetcode.com/problems/word-ladder-ii/ 这道题区别于127 Word Ladder 在于 1. 127求的是最短路径长度;本题求的是最短路径 2. 127 求的是一个值,本题求的是所有的最短路径 为了解决这个变化,关键点是 1. 对于上一层之前访问的节点我们不能再访问了 2. 对于下一层要访问的节点,我们要记录所有的路径。 class Solution: def findLadders(self, be.原创 2022-05-30 12:42:12 · 116 阅读 · 0 评论 -
[Leetcode] 127 Word Ladder 解题
class Solution: ################################################# ###### solution 3: Bi-directional BFS ###### # search from both side and check if they meet # ################################################# from collectio.原创 2022-05-30 07:08:02 · 83 阅读 · 0 评论 -
Leetcode 359 Logger Rate limit
[Leetcode] 359 Logger Rate limit class Logger: def __init__(self): # key=message(str), value=timestamp_last_sent(int) self.msg_sent = {} self.cap = 10 def shouldPrintMessage(self, timestamp: int, message: str)原创 2022-05-28 07:02:16 · 108 阅读 · 0 评论 -
Leetcode 435. Non-overlapping Intervals
Loading... DP solution class Solution: def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int: if not intervals: return 0 # initialize DP dp = [0] * len(intervals) dp[0] = 1原创 2022-05-22 01:16:09 · 107 阅读 · 0 评论 -
[Leetcode]吹响征战Leetcode的号角
写这篇,没别的意思,就是告诉自己,要开始刷Leetcode了。想起当初第一遍刷GRE单词的时候,太痛苦了,太原创 2014-09-02 17:09:34 · 711 阅读 · 0 评论