본문 바로가기
Beakjoon&프로그래머스/Java

[LeetCode/Java] 70. Climbing Stairs

by 현장 2025. 11. 22.

-Code

class Solution {
    public int climbStairs(int n) {
        int before = 0;
        int answer = 1;        

        for (int i = 0; i < n; i++) {
            int temp = answer;
            answer = before + answer;
            before = temp;
        }

        return answer;
    }
}