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 · 140 阅读 · 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 · 96 阅读 · 0 评论 -
Leetcode 359 Logger Rate limit
[Leetcode] 359 Logger Rate limitclass 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 · 130 阅读 · 0 评论 -
Leetcode 435. Non-overlapping Intervals
Loading...DP solutionclass 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 · 133 阅读 · 0 评论 -
[Leetcode]吹响征战Leetcode的号角
写这篇,没别的意思,就是告诉自己,要开始刷Leetcode了。想起当初第一遍刷GRE单词的时候,太痛苦了,太原创 2014-09-02 17:09:34 · 723 阅读 · 0 评论