728x90
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/150370#
: 개인정보 수집 유효기간
import java.util.*;
class Solution {
public int[] solution(String today, String[] terms, String[] privacies) {
System.out.println(today);
String[] todayarr = today.split("\\.");
// System.out.println(Arrays.toString(todayarr));
Map<Character, Integer> map = new HashMap<>();
for(String str : terms){
String[] a=str.split(" ");
map.put(a[0].charAt(0), Integer.valueOf(a[1]));
}
List<Integer> list = new ArrayList<>();
int cnt=0;
int a=1;
for(String str : privacies){
String[] pv = str.split(" ");
String[] arr= pv[0].split("\\.");//달
// System.out.println(Arrays.toString(arr));
int x=map.get(pv[1].charAt(0));
int y = Integer.parseInt(arr[0]);
int m = Integer.parseInt(arr[1]);
int d = Integer.parseInt(arr[2]);
int day1= d + m * 28 + (y) * 12 * 28;
y = Integer.parseInt(todayarr[0]);
m = Integer.parseInt(todayarr[1]);
d = Integer.parseInt(todayarr[2]);
int day2= d + m * 28 + (y) * 12 * 28;
System.out.println();
if(day1+(x*28)<=day2){
list.add(a);
cnt++;
}
a++;
}
System.out.println(cnt);
int[] answer = new int[cnt];
int b=0;
for(int x: list) answer[b++]=x;
return answer;
}
}
728x90
반응형
'Server Programming > BackEnd Project' 카테고리의 다른 글
63일차 - TIL (0) | 2023.02.13 |
---|---|
60일차 -TIL (0) | 2023.02.10 |
프로그래머스 Level1-정리 (0) | 2023.02.10 |
58일차 - TIL (0) | 2023.02.09 |
체육복 - Greedy, DFS (0) | 2023.02.08 |