当前位置:网站首页>Leetcode (Sword finger offer) - 10- ii Frog jumping on steps
Leetcode (Sword finger offer) - 10- ii Frog jumping on steps
2022-06-11 10:50:00 【Programmer code】
Topic link : Click to open the link
The main idea of the topic : A little .
Their thinking : A little .
Related enterprises
- Bytes to beat
- Microsoft (Microsoft)
- Google (Google)
- Bloomberg (Bloomberg)
- tencent (Tencent)
- Apple (Apple)
- Goldman Sachs Group (Goldman Sachs)
- Amazon (Amazon)
AC Code
- Java
// Solution (1)
class Solution {
public int numWays(int n) {
if (n == 0) return 1;
int[] dp = new int[n + 1];
dp[0] = dp[1] = 1;
for (int i = 2; i <= n; i++) {
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
}
return dp[n];
}
}
// Solution (2)
class Solution {
public int numWays(int n) {
int a = 1, b = 1, sum;
for(int i = 0; i < n; i++){
sum = (a + b) % 1000000007;
a = b;
b = sum;
}
return a;
}
}- C++
class Solution {
public:
int numWays(int n) {
int a = 1, b = 1, sum;
for(int i = 0; i < n; i++){
sum = (a + b) % 1000000007;
a = b;
b = sum;
}
return a;
}
};边栏推荐
猜你喜欢

Why does a ddrx power supply design require a VTT power supply
使用 Feign 实现声明式 REST 调用

International multilingual sea mall rebate product automatic matching order source code

pyspark案例系列4-dataframe输出到单个文件夹的解决方案

NFT 2.0: the next generation of NFT will be lean and trustworthy

Metro roadmap cloud development applet source code and configuration tutorial

Cloud development MBTI personality type test assistant wechat applet source code

杰理之BLE 芯片供电范围及防烧芯片措施【篇】

Pl/sql compilation check in kingbasees

Using ribbon to realize client load balancing
随机推荐
Cloud development MBTI personality type test assistant wechat applet source code
New Zealand is one of the best countries for road safety
[MySQL] use of stored procedures
Pyspark case series 4-dataframe output to a single folder solution
金仓数据库KingbaseES中的PL/SQL 编译检查
地铁路线图云开发小程序源码和配置教程
错误的导航分类横条代码版本
Hardware Description Language HDL
Cloud image quality assistant IAPP source code
Install MySQL version 5.7 or above on windows (install in compressed package)
MN梦奈宝塔主机系统V1.5版本发布
NGUI,冷却效果
Finite cyclic group
Ngui, chat scroll box, UI textlist
链接器和链接器选项、运行时库和运行时库设置、配置设置、生成过程和方法
Is it safe to open an account online? Can ordinary people drive it?
jszip 获取上传的zip包中的指定文件的file
Pl/sql compilation check in kingbasees
Common construction and capacity operation of string class
杰理之获取 BLE 出现电压检测、ADC 检测不准【篇】