Climbing Stairs
2015-06-07 14:15
344 查看
public class Solution { public int climbStairs(int n) { if (n <= 1) { return 1; } int penultimate = 1, antepenultimate = 1; int last = 0; for (int i = 2; i <= n; i++) { last = penultimate + antepenultimate; antepenultimate = penultimate; penultimate = last; } return last; } }
相关文章推荐
- 基于Android中dp和px之间进行转换的实现代码
- Android中dip、dp、sp、pt和px的区别详解
- LFC1.0.0 版本发布
- Android px、dp、sp之间相互转换
- android中像素单位dp、px、pt、sp的比较
- Android对px和dip进行尺寸转换的方法
- Android根据分辨率进行单位转换-(dp,sp转像素px)
- android 尺寸 dp,sp,px,dip,pt详解
- DP问题各种模型的状态转移方程
- TYVJ1193 括号序列解题报告
- 对DP的一点感想
- TYVJ上一些DP的解题报告
- soj1005. Roll Playing Games
- 01背包问题
- LeetCode之Maximum Product Subarray
- DP Flow
- zoj3605 Find the Marble(三维dp)
- Word Break I,II, Triangle,Palindrome Partitioning 动态规划 DP
- Unique Paths I,II, Minimum Path Sum
- Gas Station