摘要: #和之前通配符匹配很像,dp的思路 class Solution: def isMatch(self, s: str, p: str) -> bool: vertical = len(p)+1 #纵向的长度,由于有初始start因此加一 level = len(s)+1 if set(p) == { 阅读全文
posted @ 2022-07-21 17:22 是冰美式诶 阅读(25) 评论(0) 推荐(0)
摘要: #最近的算法都是考查思维而不是特定算法,值得一试 #按层 class Solution: def trap(self, height: List[int]) -> int: n=len(height) left,right=0,n-1 tmp,high=0,1 while(left<=right): 阅读全文
posted @ 2022-07-21 17:19 是冰美式诶 阅读(78) 评论(0) 推荐(0)
摘要: #偷巧法 #正整数是指大于0的数,那想到添加参数0,然后进行比较 #如果是连续的就返回最后一个值,否则返回跳跃的那个值 class Solution: def firstMissingPositive(self, nums: List[int]) -> int: nums.append(0) num 阅读全文
posted @ 2022-07-21 17:13 是冰美式诶 阅读(27) 评论(0) 推荐(0)