当前位置:网站首页>leetcode 91. Decode Ways 解码方法(中等)
leetcode 91. Decode Ways 解码方法(中等)
2022-06-23 03:47:00 【InfoQ】
一、题目大意
- 1 <= s.length <= 100
- s 只包含数字,并且可能包含前导零。
二、解题思路
三、解题方法
3.1 Python实现
class Solution(object):
def numDecodings(self, s):
"""
:type s: str
:rtype: int
"""
dp = [0] * (len(s) + 1)
dp[0] = 1
for i in range(1, len(dp)):
if s[i-1] != '0':
dp[i] = dp[i-1]
if i != 1 and '09' < s[i-2:i] < '27':
dp[i] += dp[i-2]
return dp[-1]
四、总结小记
- 2022/6/22 试着用Python解决leetcode
边栏推荐
- 直接插入排序
- [tcapulusdb knowledge base] [list table] example code of batch deleting data at specified location in the list
- 【LeetCode】23. Merge K ascending linked lists
- 怎样能在小程序中实现视频通话及互动直播功能?
- Source code encryption of data encryption technology
- 1-1 introduction to VMWare
- Common events for elements
- Software project management 8.4 Software project quality plan
- Pyspark, paid for data cleaning and uploading to the database
- Bug STM32 interrupt (everyone knows)
猜你喜欢
随机推荐
怎么用好MySQL索引
Questions about SQL statements
京东云分布式数据库StarDB荣获中国信通院 “稳定性实践先锋”
[machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation
Software project management 8.4 Software project quality plan
仿360桌面悬浮球插件
在线文本过滤小于指定长度工具
PTA:7-69 数据的间距问题
两招提升硬盘存储数据的写入效率
mysql,字段问题
[binary tree] 993 Cousins in Binary Tree
JS array de duplication, removing the same value
静态查找表和静态查找表
[tcapulusdb knowledge base] [list table] sample code for inserting data into the specified position in the list
【LeetCode】23. Merge K ascending linked lists
Create a desktop shortcut to your appimage
基于FPGA的VGA协议实现
[OWT] OWT client native P2P E2E test vs2017 build 3: no test unit comparison, manually generate vs projects
在 KubeSphere 上部署 Apache Pulsar
基于HAProxy实现网页动静分离


![[greed] leetcode991 Broken Calculator](/img/6e/ce552b55899c6e8d3c37f524f99f82.png)






