Climbing stairs
2015-09-25 10:33
489 查看
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?
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
public class Solution { public int climbStairs(int n) { int[] count = new int[n+1]; if(n<=1)return n; count[0]=1; //注意这个得赋值为1,之后才可以正常运行 count[1]=1; for(int i=2;i<=n;i++) { count[i]=count[i-1]+count[i-2]; } return count ; } }
相关文章推荐
- 发送email 打开email
- Training
- 用fail2ban解决暴力破解,你设定成登陆失败3次封锁该IP小时,按RSA的加密等级他得算上好久
- maven install Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-wa
- mysql failed to open file
- Async and Await 异步和等待
- RAID技术介绍和总结
- mongoDB启动报错 ERROR: child process failed, exited with error number
- http://blog.csdn.net/fufeihappy/article/details/6060763 你知道linux每个文件夹下都是什么吗?
- Factorial Trailing Zeroes
- HDU 3394 Railway(点双连通分量与桥)
- AIDL相关的解释远程service和client处理
- rotate图片旋转 http://blog.csdn.net/lonelyroamer/article/details/8252533
- MethodInvokingJobDetailFactoryBean的并发问题
- blog is waiting for you
- Could not obtain transaction-synchronized Session for current thread
- Linux sync命令的作用 http://blog.csdn.net/holandstone/article/details/7356865
- HDU 2476 String painter(记忆化搜索, DP)
- copypng emitted errors but did not return a nonzero exit code to indicate failure
- 超级块与索引节点 http://blog.csdn.net/ilsas/article/details/5627348