티스토리 뷰
class Solution {
public static String solution(int a, int b) {
int[] days = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
String[] day_week = { "THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED" };
int totalDays = 0;
if (a == 1) {
totalDays = b;
} else {
for (int i = 0; i < a-1; i++) {
totalDays += days[i];
}
totalDays += b;
}
return day_week[totalDays%7];
}
}
- 적다보니까 규칙이 보여서 월마다의 일수배열, 요일배열 만들어서 풀이
- 총 일수를 구하고 요일 배열에서 %7 을한 값
class TryHelloWorld
{
public String getDayName(int month, int day)
{
Calendar cal = new Calendar.Builder().setCalendarType("iso8601")
.setDate(2016, month - 1, day).build();
return cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, new Locale("ko-KR")).toUpperCase();
}
public static void main(String[] args)
{
TryHelloWorld test = new TryHelloWorld();
int a=5, b=24;
System.out.println(test.getDayName(a,b));
}
}
- 다른 사람 풀이 중 이런게 있었는데 봐도 나중에 쓰기 힘들 것 같다
반응형
'PS > programmers' 카테고리의 다른 글
Level1) 나누어 떨어지는 숫자 배열 (0) | 2020.09.08 |
---|---|
Level1) 같은 숫자는 싫어 (0) | 2020.09.08 |
Level1) 가운데 글자 가져오기 (0) | 2020.09.08 |
Level1) 모의고사 (0) | 2020.09.08 |
Level1) 체육복 (0) | 2020.09.08 |
링크
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 패스트캠퍼스 컴퓨터공학 완주반
- 김영한 JPA
- JPA 연관관계 매핑
- JS 딥다이브
- dreamcoding
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- HTTP 완벽 가이드
- HTTP 완벽가이드
- 드림코딩
- js api
- 이펙티브자바 아이템60
- Spring Security
- 모던자바스크립트
- java
- 킹수빈닷컴
- js array
- 이펙티브자바 스터디
- 집 구하기
- BOJ
- 김영한 http
- REST API
- 이펙티브자바
- js promise
- 백준
- 프로그래머스 SQL
- 이펙티브자바 아이템59
- http
- 백기선 스터디
- 프로그래머스
- GCP
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함