当前位置:网站首页>剑指 Offer 10- II. 青蛙跳台阶问题
剑指 Offer 10- II. 青蛙跳台阶问题
2022-06-26 23:41:00 【anieoo】
solution:
class Solution {
public:
int numWays(int n) {
if(n <= 1) return 1;
vector<int> dp(n + 1);
dp[0] = 1;
dp[1] = 1;
for(int i = 2;i <= n;i++) {
dp[i] = (dp[i - 1] + dp[i -2]) % 1000000007;
}
return dp[n];
}
};
边栏推荐
- 冲刺强基计划数学物理专题二
- go语言的爬虫和中间件
- 如何通俗易懂的描述机器学习的流程?
- 浅谈分布式系统开发技术中的CAP定理
- [vscode] setting sync, a plug-in for synchronizing extensions and settings
- Can't write to avoid killing and can easily go online CS through defender
- Understanding of "the eigenvectors corresponding to different eigenvalues cannot be orthogonalized"
- Amway! How to provide high-quality issue? That's what Xueba wrote!
- 【Try to Hack】正向shell和反向shell
- leetcode 1143. Longest common subsequence (medium)
猜你喜欢
Unity初学者肯定能用得上的50个小技巧
On cap theorem in distributed system development technology
当Transformer遇见偏微分方程求解
kubeadm创建kubernetes集群
Pinpoint attackers with burp
The user adds a timer function in the handler () goroutine. If it times out, it will be kicked out
Color matching and related issues
Alibaba cloud server purchase, basic configuration, (xshell) remote connection and environment building
巧记大小端字节序
[微服務]認識微服務
随机推荐
CVE-2022-30190 Follina Office RCE分析【附自定义word模板POC】
入侵痕迹清理
客户端实现client.go客户端类型定义连接
当Transformer遇见偏微分方程求解
No clue about complex data?
[micro service]nacos
邮箱附件钓鱼常用技法
How do new investors open accounts online? Is it safe to open accounts online and speculate in stocks
Safe and cost-effective payment in Thailand
How to use Pinia (I) introduce Pinia into the project
超硬核!华为智慧屏上的家庭相册竟可以自动精准分类?
Tensorrt笔记(七)Tensorrt使用问题整理
买基金在哪里开户买比较安全
Color matching and related issues
Operations research says that in issue 66, Behrman also has "speech phobia"?
巧记大小端字节序
Lorsque le transformateur rencontre l'équation différentielle partielle
Is it safe to buy pension insurance online? Is there a policy?
CVPR2022-不对称分辨率图像的立体匹配
技术干货|极速、极智、极简的昇思MindSpore Lite:助力华为Watch更加智能