Climbing Stairs
2015-06-05 04:10
429 查看
public class Solution { public int climbStairs(int n) { int[] res =new int[n+3]; // 因为如果n<3,至少希望把前三个位置做出来 res[0] = 0; res[1] =1; res[2] = 2; if(n<3) return res ; for(int i=3;i<=n;i++){ res[i] = res[i-1]+res[i-2]; } return res ; } }
相关文章推荐
- 从main函数中argc和argv开始学习
- [LOJ 1038] Race to 1 Again
- How did your survive waiting
- TurboMail智能防御企业邮箱盗号和退信攻击
- tools:context=".MainActivity的作用
- 用libaio读写文件时遇到的问题
- UVA514 Rails
- UVA442 Matrix Chain Multiplication
- light oj 1038 - Race to 1 Again(概率dp求期望 记忆化搜索)
- rails4.2~devise邮箱测试
- hdu 5009 Paint Pearls
- HDU 2476 - String painter(区间DP)
- 【leetcode】Contains Duplicate II
- suspend() 和 resume() 方法,notify()和wait()方法区别
- Splay树(区间添加删除 | 区间翻转)——HDU 3487 Play with Chain
- sizeWithFont:constrainedToSize:转boundingRectWithSize:options:
- msdb.dbo.sp_send_dbmail 用法简介
- MacBook Air装单独win7
- Message和obtainMessage的区别
- hdu 2057 a + b again