leetcode 70. Climbing Stairs
2017-06-02 21:49
435 查看
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer.
an=an−1+an−2
a0=a1=1
public class Solution { public int climbStairs(int n) { int a = 1, b = 1; while(--n>0){ a = (b+=a) - a; } return b; } }
相关文章推荐
- Leetcode:70. Climbing Stairs(JAVA)
- leetcode之70. Climbing Stairs(C++解法 动态规划思想)
- leetcode 70. Climbing Stairs
- Leetcode 70. Climbing Stairs
- LeetCode 70. Climbing Stairs (O(n)时间, O(1)空间实现)
- [leetcode]70. Climbing Stairs
- LeetCode 70. Climbing Stairs
- Leetcode 70. Climbing Stairs
- LeetCode70. Climbing Stairs
- [leetcode] 70. Climbing Stairs
- leetcode 70. Climbing Stairs
- [勇者闯LeetCode] 70. Climbing Stairs
- 【LeetCode】70. Climbing Stairs
- [leetcode]: 70. Climbing Stairs
- LeetCode [DP]70. Climbing Stairs
- LeetCode70. Climbing Stairs
- LeetCode 70. Climbing Stairs
- leetcode--70. Climbing Stairs
- Leetcode-70. Climbing Stairs
- 【leetcode】70. Climbing Stairs