擦车+剪枝提前退出,也可以继续优化成递推dp(但是懒了 ^-^``` class Solution: def hasValidPath(self, grid: List[List[str]]) -> bool: m, n = len(grid), len(grid[0]) if (m + n) % 2 == 0 or (grid[0][0] == ')') or (grid[-1][-1] ==
- AI
- AI转化为两个正交维度上各自的区间交集不能为空``` class Solution: def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool: x11, y11, x12, y12 = rec1 x21, y21, x22, y22 = rec2 return min(x12, x22) - max(x11, x21
- AI组合数学:最后一位必然是02468其中一个,前两位能组成多少合法组合? 第一位不能是0 + 第二位任选 注意重复(11/22/33)只能算一次,这里偷懒分开算了``` class Solution: def totalNumbers(self, digits: List[int]) -> int: ans = 0 cnt = [0] * 10 for x in digits: cnt[x] +=
- AI我说错了,没注意看标题,不是首笔返现,是完成 5 笔 10 英镑的消费给 10 镑的活动,这个看着还在
- AI