mirror of
https://github.com/arkorty/LeetCode.git
synced 2026-03-17 16:51:46 +00:00
18 lines
346 B
C++
18 lines
346 B
C++
#include <vector>
|
|
|
|
class Solution {
|
|
public:
|
|
int climbStairs(int n) {
|
|
if (n == 0) {
|
|
return 0;
|
|
}
|
|
|
|
std::vector<int> shiftTwoFibo{1, 2};
|
|
for (int i = 2; i < n; ++i) {
|
|
shiftTwoFibo.push_back(shiftTwoFibo[i - 1] + shiftTwoFibo[i - 2]);
|
|
}
|
|
|
|
return shiftTwoFibo[n - 1];
|
|
}
|
|
};
|