Skip to content

Commit 1e2c014

Browse files
update 70
1 parent fd3ec41 commit 1e2c014

File tree

1 file changed

+6
-6
lines changed
  • src/main/java/com/fishercoder/solutions/firstthousand

1 file changed

+6
-6
lines changed

src/main/java/com/fishercoder/solutions/firstthousand/_70.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ public int climbStairs(int n) {
2929
if (n == 1) {
3030
return n;
3131
}
32-
int stepOne = 1;
33-
int stepTwo = 2;
32+
int secondLastStep = 1;
33+
int lastStep = 2;
3434
for (int i = 3; i <= n; i++) {
35-
int tmp = stepTwo;
36-
stepTwo = stepOne + stepTwo;
37-
stepOne = tmp;
35+
int tmp = lastStep;
36+
lastStep = secondLastStep + lastStep;
37+
secondLastStep = tmp;
3838
}
39-
return stepTwo;
39+
return lastStep;
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)