Every day a Leetcode
题目来源:2391. 收集垃圾的最少总时间
解法1:前缀和
收集垃圾的时间分为两部分:
垃圾车收拾垃圾的时间:垃圾车收拾一单位的任何一种垃圾都需要花费 1 分钟。三辆垃圾车行驶的时间:每辆垃圾车…
题目: 题解:
class Solution:def numDecodings(self, s: str) -> int:n len(s)# a f[i-2], b f[i-1], c f[i]a, b, c 0, 1, 0for i in range(1, n 1):c 0if s[i - 1] ! 0:c bif i > 1 and s[i - 2] ! 0 and int(s[i-2:i]) < 26:c aa,…