当前位置:网站首页>[early spring 2022] [leetcode] 91 Decoding method
[early spring 2022] [leetcode] 91 Decoding method
2022-06-09 06:03:00 【Well of】
A typical topic , Spell words
Note that the two states add up , It's not just +1, And pay attention to the problem of subscript
class Solution {
public int numDecodings(String s) {
int[] dp = new int[s.length()+1];
dp[0] = 1;
for(int i=1; i<=s.length(); i++){
if(s.charAt(i-1)!='0') dp[i] = dp[i-1];
if(i>1&&s.charAt(i-2)!='0'&&((s.charAt(i-2)-'0')*10+(s.charAt(i-1)-'0')<=26)){
dp[i] += dp[i-2];
}
}
return dp[s.length()];
}
}
边栏推荐
- Quelles sont les informations contenues dans le certificat SSL?
- Complete webrtc video recording in five minutes
- run LK in Qemu
- Allocation principle of IP address
- DBeaver导出查询数据sql文件
- Itop-2k1000 development board startup ramdisk production startup USB flash disk
- Detailed understanding and learning of transactions in MySQL (transaction management, transaction isolation level, transaction propagation mechanism)
- el-table滚动条样式
- Analysis of the most complete webrtc server technology selection in history
- One side of a small company in Hangzhou
猜你喜欢

Tensorflow introductory tutorial 02 basic concepts of tensorflow (data flow graph, tensor, tensorboard)

MySql中事务详细理解学习(事务管理、事务隔离级别、事务传播机制)

How to solve the garbled code in the query statement when MySQL uses fuzzy query for Chinese

One side of a small company in Hangzhou

Topic26——11. Container with the most water

Here comes the era of metaltc2.0

JVM basic theory.

IP地址的分配原理

SSL證書包含了哪些信息?

XML modeling
随机推荐
Topic26——11. Container with the most water
C#字符串用法集合
Allocation principle of IP address
C# 特殊语法
JVM basic theory.
Topic26——11. 盛最多水的容器
A guide to signing adobe air applications using code signing certificates
杭州某家小公司一面
Three queues CXQ, entrylist, waitset personal understanding analysis
Ctf: find the most collinear points in the point set
Detailed understanding and learning of transactions in MySQL (transaction management, transaction isolation level, transaction propagation mechanism)
[reprint] LCD common interface principle
1433:【例题1】愤怒的牛
Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) D. Jon and Orbs
SSL證書包含了哪些信息?
About the problem of code wrapping when formatting code with vscode
传输介质双绞线和光纤及二进制
Mvcc multi version control
VK Cup 2017 - Round 2 B. Volatile Kite
Build tool gradle