Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21.06.24 - [PG] 2016년 #93

Closed
suhyunsim opened this issue Jun 24, 2021 · 0 comments
Closed

21.06.24 - [PG] 2016년 #93

suhyunsim opened this issue Jun 24, 2021 · 0 comments
Assignees
Labels
lv.1 프로그래머스 - level 1 실패 시도했지만 맞지 못한 문제

Comments

@suhyunsim
Copy link
Owner

suhyunsim commented Jun 24, 2021

문제

핵심 아이디어

어려운 점, 실수

  • 1월 1일 count를 고려하지 못했다.(1월 1일은 첫번재 요일이 되어야 하는데 카운트 되어버림 -> -1해서 고려해줘야 함)

풀이

package main.java.com.poogle.PG.Q12901;

public class Solution {
    public static void main(String[] args) {
        System.out.println(solution(5, 24));
    }

    public static String solution(int a, int b) {
        String[] year = new String[366];
        int[] month = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        String[] days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        for (int i = 0; i < year.length; i++) {
            year[i] = days[(i + 5) % 7];
        }
        int ans = 0;
        for (int i = 0; i < a - 1; i++) {
            ans += month[i];
        }
        ans += b - 1;
        return year[ans];
    }
}
@suhyunsim suhyunsim added 실패 시도했지만 맞지 못한 문제 lv.1 프로그래머스 - level 1 labels Jun 24, 2021
@suhyunsim suhyunsim added this to the 6월 4주 차 milestone Jun 24, 2021
@suhyunsim suhyunsim self-assigned this Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lv.1 프로그래머스 - level 1 실패 시도했지만 맞지 못한 문제
Projects
None yet
Development

No branches or pull requests

1 participant