Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int climbStairs(int n) {
- if (n <= 1) {
- return 1;
- }
- int prev = 1;
- int current = 1;
- for (int i=2; i<=n; ++i) {
- int next = prev + current;
- prev = current;
- current = next;
- }
- return current;
- }
- }
Add Comment
Please, Sign In to add comment