[プログラマー]コードテスト練習-練習問題第1級2016年



Solution.java

class Solution {
    public String solution(int a, int b) {
        String answer = "";
        
        String[] day = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
        int[] days = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        
        int tmp = b;
        for (int i = 1; i < a; i++) {
            tmp += days[i];
        }
        
        answer = day[(4 + tmp) % 7];
        
        return answer;
    }
}
出典:プログラマーコードテスト練習、https://programmers.co.kr/learn/challenges