Leetcode / climbing-stairs
Pick a programming language:
Here is the source code for the solution to this problem.
class Solution {
public int climbStairs(int n) {
int prev = 1;
int curr = 1;
for (int i = 1; i < n; i++)
{
int temp = curr;
curr = curr + prev;
prev = temp;
}
return curr;
}
}
Gostou da aula? 😆👍
Apoie nosso trabalho com uma doação: