Advertisement
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 first = 1;
- int second = 2;
- for(int i = 3; i <= n; i++) {
- int third = first + second;
- first = second;
- second = third;
- }
- return second;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement