111_climbing-stairs
/*
@Copyright:LintCode
@Author: Monster__li
@Problem: http://www.lintcode.com/problem/climbing-stairs
@Language: Java
@Datetime: 17-03-05 05:12
*/
public class Solution {
/**
* @param n: An integer
* @return: An integer
*/
public int climbStairs(int n) {
//int sumways=0;
//int step_index,i;
//int steps[]={1,2};
int step[]=new int[1024];
step[0]=1;step[1]=1;
//step[2]=2;
for(int step_index=2;step_index<=n;step_index++)
{
step[step_index]=step[step_index-1]+step[step_index-2];
}
/*
class climbtest{
int climb(int steps)
{
if(steps<n)
return climb(++steps);
else return sumways;
}
}
*/
/*
if(n>1)
return climbStairs(n);
else return sumways;
*/
return step[n];
}
}
111_climbing-stairs的更多相关文章
- [LeetCode] Climbing Stairs 爬梯子问题
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- [LintCode] Climbing Stairs 爬梯子问题
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- Leetcode: climbing stairs
July 28, 2015 Problem statement: You are climbing a stair case. It takes n steps to reach to the top ...
- LintCode Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- 54. Search a 2D Matrix && Climbing Stairs (Easy)
Search a 2D Matrix Write an efficient algorithm that searches for a value in an m x n matrix. This m ...
- Climbing Stairs
Climbing Stairs https://leetcode.com/problems/climbing-stairs/ You are climbing a stair case. It tak ...
- 3月3日(6) Climbing Stairs
原题 Climbing Stairs 求斐波那契数列的第N项,开始想用通项公式求解,其实一个O(n)就搞定了. class Solution { public: int climbStairs(int ...
- Cllimbing Stairs [LeetCode 70]
1- 问题描述 You are climbing a stair case. It takes n steps to reach to the top. Each time you can eithe ...
- leetCode 70.Climbing Stairs (爬楼梯) 解题思路和方法
Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you ...
- 【LeetCode练习题】Climbing Stairs
Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you c ...
随机推荐
- solr笔记之solr下载及安装
在学习solr过程中,磕磕碰碰,遇到过许多问题,所以特写下笔记,以供需要的时候时常翻阅,也给能看到该博文的博友提供一个不全面的参考. 一.solr简介: Solr是一个独立的企业及搜索应用服务器,它对 ...
- 配置Server Side TAF
实验环境:Oracle 11.2.0.4 RAC 参考MOS文档: How To Configure Server Side Transparent Application Failover (文档 ...
- Java 数值类型以及计算
前段时候写了一个对外提供的接口,其中有一个数值校验的计算.在测试的过程中发现5.6-1.6 != 4,在反复的测试过程中发现double类型的数值为有精度丢失的现象,看来还是基础知识不牢固,所以就在网 ...
- nodejs学习第一天之模块
1.运行js文件 2.node 与 js 的区别 相同:数据类型,语法结构,对象 等基本一致 不同:在js中的顶层对象window 在node中没有在node中 顶层对象为global对象 其不对外 ...
- Vue学习之路---No.5(分享心得,欢迎批评指正)
同样,首先我们还是回顾一下昨天讲到的东西: 1.常用的Vue修饰器 2.当利用js方法不修改数据,但也可以改变视图时,我们需要整体返回再整体接收 (如: items.example1 = items. ...
- java-信息安全(五)-非对称加密算法RSA
概述 信息安全基本概念: RSA算法(Ron Rivest.Adi Shamir.Leonard Adleman,人名组合) RSA RSA公钥加密算法是1977年由罗纳德·李维斯特(Ron Rive ...
- 模拟一个shuffle
之所以会想到写这么一个shuffle的例子,是因为一个需求:我需要把一个有序数组中的数据随机的打散.java代码如下, public void shuffle() { int[] arr = {1,2 ...
- TCP协议之三次握手与四次挥手
TCP协议是TCP/IP体系中核心一个协议,该协议比起IP协议,ICMP协议,UDP协议都更复杂,因此这篇文章主要分析TCP协议在建立连接和断开连接的时候,状态转移以及报文段的内容. 下面,先放一张T ...
- MySql Table错误:is marked as crashed and last (automatic?) 和 Error: Table "mysql"."innodb_table_stats" not found
一.mysql 执行select 的时候报Table错误:is marked as crashed and last (automatic?) 解决方法如下: 找到mysql的安装目录的bin/myi ...
- javascript 数组的部分常用属性用法
数组 检测数组(返回布尔类型 a. instanceof(); 检测是否是数组对象 console.log(arr instanceof Array) ; b. Array.isArray() ,H5 ...