70.Climbing Stairs
来源:互联网 发布:淘宝企业c店开店流程 编辑:程序博客网 时间:2024/04/25 22:23
题目链接:climbing-stairs
/** * 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? * */public class ClimbingStairs {//45 / 45 test cases passed.//Status: Accepted//Runtime: 183 ms//Submitted: 0 minutes ago//解题思路:要爬到第n阶楼梯,有两种情况://一、 从第(n - 1)阶出发 一次一步到//二、 从第(n - 2)阶出发 一次两步到//故就是以上两种情况之和,为斐波那契数列 static int climbStairs(int n) { if(n == 0) return 0; if(n == 1) return 1; int[] count = new int[n + 1]; count[0] = 0; count[1] = 1; count[2] = 2; for (int i = 3; i <= n; i++) {count[i] = count[i - 1] + count[i - 2];} return count[n]; }public static void main(String[] args) {System.out.println(climbStairs(5));}}
0 0
- [LeetCode]70.Climbing Stairs
- 70.Climbing Stairs
- LeetCode --- 70. Climbing Stairs
- [Leetcode] 70. Climbing Stairs
- [leetcode] 70.Climbing Stairs
- 70.Climbing Stairs
- 70. Climbing Stairs
- 70.Climbing Stairs
- 70. Climbing Stairs
- [leetCode]70. Climbing Stairs
- 70. Climbing Stairs
- 70. Climbing Stairs LeetCode
- 70. Climbing Stairs
- 70. Climbing Stairs
- 70. Climbing Stairs
- [LeetCode]70. Climbing Stairs
- 【LeetCode】70. Climbing Stairs
- 70. Climbing Stairs
- Android Volley完全解析(四),带你从源码的角度理解Volley
- dp(good)UVa10401 - Injured Queen Problem
- 根据指定名称获取Cookie
- Rayeager PX2在linux下adb 设备驱动
- R语言做文本挖掘 Part5情感分析
- 70.Climbing Stairs
- Java Date类加减天数常遇到的问题
- Linux内核源代码情景分析-wait()、schedule()
- SELinux策略语言--类型强制(编写TE规则)
- Activiti的servicetask 调用Spring中Bean
- 详解Spring中的CharacterEncodingFilter
- iOS好用的开源库
- 创建windows services 实现定时操作 提供调试方法
- 在LATEX中设置页眉页脚以及页码