Skip to content

Commit fb0dfb7

Browse files
author
wb-hjk570755
committed
跳阶梯
1 parent c7fb61e commit fb0dfb7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/com/blankj/myself/SkipLadder.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.blankj.myself;
2+
3+
/**
4+
* Description:
5+
* Copyright: Copyright (c) 2012
6+
* Company: keruyun Technology(Beijing) Chengdu Co. Ltd.
7+
*
8+
* @author huangjk
9+
* @version 1.0 2020/5/20
10+
*/
11+
public class SkipLadder {
12+
public static void main(String[] args) {
13+
14+
}
15+
16+
public int climbStairs(int n) {
17+
if(n==1){
18+
return 1;
19+
}
20+
int[] nums = new int[n];
21+
nums[0] = 1;
22+
nums[1] = 2;
23+
for (int i=2;i<n;i++){
24+
nums[i] = nums[i-2] + nums[i-1];
25+
}
26+
return nums[n-1];
27+
}
28+
}

0 commit comments

Comments
 (0)