标签:color class info 结果 def python3 内存 span ==
class Solution: def numDecodings(self, s: str) -> int: a={} if int(s[0])==0: return 0 else: a[0]=1 if len(s)==1: return a[0] if int(s[0])>2 and int(s[1])==0: a[1]=0 if len(s)>1: return 0 if (int(s[0]+s[1])>26) or (int(s[0])<3 and int(s[1])==0): a[1]=1 elif int(s[0]+s[1])<=26: a[1]=2 #print(a) if len(s)==2: return a[1] for i in range(2,len(s)): if s[i-1]==‘0‘ and s[i]==‘0‘: return 0 elif int(s[i-1])>2 and s[i]==‘0‘: return 0 elif (int(s[i-1]+s[i]))>26 or (s[i-1]==‘0‘ and int(s[i])!=0): a[i]=a[i-1] elif int(s[i-1])<3 and s[i]==‘0‘: a[i]=a[i-2] elif int(s[i-1]+s[i])<=26: a[i]=a[i-1]+a[i-2] else: a[i]=a[i-1] return a[len(s)-1]
标签:color class info 结果 def python3 内存 span ==
原文地址:https://www.cnblogs.com/taoyuxin/p/11676790.html