# Climbing Stairs

class Solution {
public:
int climbStairs(int n) {
//其实是斐波那契数列的变形问题，f(n) = f(n-1) + f(n-2)
int last1 = 1, last2 = 1;//f0 = 1, f1 = 1
int result = 1;
for(int i = 2;i<=n;i++)
{
result = last1 + last2;
last1 = last2;
last2 = result;
}

return result;
}
};

• 本文已收录于以下专栏：

## leetcode Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb...

## 【LeetCode-面试算法经典-Java实现】【073-Climbing Stairs（爬楼梯）】

【070-Climbing Stairs（爬楼梯）】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题　　You are climbing a stair case. It ta...

## Leetcode 70. Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1...

## Leetcode note--Leetcode 70climbing Stairs

70. Climbing Stairs  My Submissions Total Accepted: 143040Total Submissions: 37227...

## LeetCode 70 Climbing Stairs（爬楼梯）（动态规划）（*）

• NoMasp
• 2016-01-14 07:12
• 3862

## Climbing Stairs爬楼梯啊爬楼梯（支持n step）

leetcode原题 You are climbing a stair case. It takes n steps to reach to the top. Each time you ...

## [LeetCode]70.Climbing Stairs

【题目】 You are climbing a stair case. It takes n steps to reach to the top. Each time you can eithe...

## leetcode解题之70 #Climbing Stairs Java版 （青蛙跳台阶）

leetcode解题之70 #Climbing Stairs Java版 （青蛙跳台阶）

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)