We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd3ec41 commit 1e2c014Copy full SHA for 1e2c014
src/main/java/com/fishercoder/solutions/firstthousand/_70.java
@@ -29,14 +29,14 @@ public int climbStairs(int n) {
29
if (n == 1) {
30
return n;
31
}
32
- int stepOne = 1;
33
- int stepTwo = 2;
+ int secondLastStep = 1;
+ int lastStep = 2;
34
for (int i = 3; i <= n; i++) {
35
- int tmp = stepTwo;
36
- stepTwo = stepOne + stepTwo;
37
- stepOne = tmp;
+ int tmp = lastStep;
+ lastStep = secondLastStep + lastStep;
+ secondLastStep = tmp;
38
39
- return stepTwo;
+ return lastStep;
40
41
42
0 commit comments