GaGe

[프로그래머스] 2 x n 타일링 - java 본문

알고리즘/[2020] 프로그래머스

[프로그래머스] 2 x n 타일링 - java

Sorrel 2020. 6. 6. 17:44
class Solution {
    public int solution(int n) {
        int answer = 0;
        int a=1;
        int b=1;
        for(int i = 1 ; i<=n ; i++){
            if(i ==1){
                answer=1;
            }
            if(i==2){
                answer=2;
            }
            else{
                int c = (a + b) % 1000000007;
                a=b;
                b=c;
            }
        }
        return b;
    }
}
Comments