프로그래머스 - 2016년

꽃봉우리·2024년 6월 17일

알고리즘 카타

My Code

class Solution {
    public String solution(int a, int b) {
        String[] days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        int[] months = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
        int total = 0;
        
        for(int i=0; i<a; i++) {
            total += months[i];
        }
        total += b;

        return days[(total + 4) % 7];
    }
}

0개의 댓글