728x90
https://school.programmers.co.kr/learn/courses/30/lessons/150370
static ArrayList<Integer> solution(String today, String[] terms, String[] privacies) {
ArrayList<Integer> answer = new ArrayList<>();
Map<String, Integer> map = new HashMap<>();
for(String str : terms){
map.put(str.split(" ")[0],Integer.parseInt(str.split(" ")[1]));
}
int t_year = Integer.parseInt(today.split("\\.")[0])*12*28;
int t_month = Integer.parseInt(today.split("\\.")[1])*28;
int t_day = Integer.parseInt(today.split("\\.")[2]);
int t_total = t_year+t_month+t_day;
for(int i=0;i<privacies.length;i++){
int ep = map.get(privacies[i].split(" ")[1])*28-1;
String enrollment = privacies[i].split(" ")[0];
int year = Integer.parseInt(enrollment.split("\\.")[0])*12*28;
int month = Integer.parseInt(enrollment.split("\\.")[1])*28;
int day = Integer.parseInt(enrollment.split("\\.")[2]);
if(t_total > year+month+day+ep){
answer.add(i+1);
}
}
return answer;
}
728x90
'🐣 알고리즘 삐약 > ✏️ 냅다 덤벼보는 문제풀이' 카테고리의 다른 글
[프로그래머스] LV1. 가장 많이 받은 선뭉 | JAVA (0) | 2024.08.16 |
---|---|
[프로그래머스] LV2. 택배 배달과 수거하기 | JAVA (0) | 2024.08.15 |
[codeforces] Ebony and Ivory | Cpp (0) | 2022.05.24 |
[C++] UVa 10718 : Bit Mask (0) | 2022.04.21 |
[UVa 10382 ] Watering Grass (0) | 2022.04.21 |