File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public int climbStairs (int n ) {
3
+ int prev1 =1 , prev2 =2 , cur =0 ;
4
+ if (n <=2 ) return n ;
5
+ for (int i =3 ;i <=n ;++i ) {
6
+ cur =prev1 +prev2 ;
7
+ prev1 =prev2 ;
8
+ prev2 =cur ;
9
+ }
10
+ return cur ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change @@ -291,6 +291,7 @@ Check out ---> [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu
291
291
| 72 | [ Edit Distance] ( https://leetcode.com/problems/edit-distance/ ) | [ Python] ( ./Python/edit-distance.py ) | _ O(N\* M)_ | _ O(n^2)_ | Medium | Levenshtein Distance | |
292
292
| 91 | [ Decode ways] ( https://leetcode.com/problems/decode-ways/ ) | [ Python] ( ./Python/decode-ways.py ) | _ O(N)_ | _ O(N)_ | Easy | DP | |
293
293
| 1025 | [ Divisor Game] ( https://leetcode.com/problems/divisor-game/ ) | [ Python] ( ./Python/divisor-game.py ) | _ O(N^2)_ | _ O(N)_ | Easy | DP | |
294
+ | 070 | [ Climbing Stairs] ( https://leetcode.com/problems/climbing-stairs/ ) | [ Java] ( ./Java/climbing-stairs.java ) | _ O(N)_ | _ O(1)_ | Easy | DP | |
294
295
295
296
<br />
296
297
<div align =" right " >
You can’t perform that action at this time.
0 commit comments