We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 932b4f5 commit bb02823Copy full SHA for bb02823
climbing-stairs/Hong-Study.cpp
@@ -0,0 +1,18 @@
1
+class Solution {
2
+public:
3
+ int climbStairs(int n) {
4
+ std::map<int, int> stepMap;
5
+ stepMap[1] = 1;
6
+ stepMap[2] = 2;
7
+
8
+ if (n == 1) {
9
+ return stepMap[n];
10
+ }
11
12
+ for (int i = 3; i <= n; i++) {
13
+ stepMap[i] = stepMap[i - 1] + stepMap[i - 2];
14
15
16
17
18
+};
0 commit comments