반응형
문제 풀이
문제 풀이
import java.util.*;
class Solution {
public int[] solution(String today, String[] terms, String[] privacies) {
List<Integer> list = new ArrayList<>();
HashMap<String, String> map = new HashMap<>();
for (int i = 0; i < terms.length; i++) {
map.put(terms[i].split(" ")[0], terms[i].split(" ")[1]);
}
int year = Integer.parseInt(today.split("\\.")[0]);
int month = Integer.parseInt(today.split("\\.")[1]);
int day = Integer.parseInt(today.split("\\.")[2]);
for (int i = 0; i < privacies.length; i++) {
String date = privacies[i].split(" ")[0];
int type = Integer.parseInt(map.get(privacies[i].split(" ")[1]))*28;
int num = (year - Integer.parseInt(date.split("\\.")[0]))*28*12
+ (month - Integer.parseInt(date.split("\\.")[1]))*28
+ (day - Integer.parseInt(date.split("\\.")[2]));
if (num >= type) {
list.add(i+1);
}
}
return list.stream().filter(i -> i != null).mapToInt(i -> i).toArray();
}
}
반응형
'TIL(Today I Learned)' 카테고리의 다른 글
99클럽 코테 스터디 2일차 TIL + [백준] 10820 : 문자열 분석 (0) | 2025.04.01 |
---|---|
99클럽 코테 스터디 1일차 TIL + [백준] 1032 : 명령 프롬프트 (0) | 2025.03.31 |
[TIL] 99클럽 코테 스터디 33일차 TIL + 프로그래머스 신규 아이디 추천 (0) | 2024.11.29 |
[TIL] 99클럽 코테 스터디 32일차 TIL + 백준 11054 가장 긴 바이토닉 부분 수열 (1) | 2024.11.28 |
[TIL] 99클럽 코테 스터디 31일차 TIL + 백준 2631 줄세우기 (0) | 2024.11.27 |