오늘 날짜로 파기해야 할 개인정보를 구하는 것이다.
모든 달은 28일까지 있다고 가정한 것을 유의해서 풀면 된다.
function solution(today, terms, privacies) {
let deleteTerm = [];
let termInfo = {};
let [year, month, date] = today.split(".").map(Number);
let todayCount = year * 12 * 28 + month * 28 + date;
terms.forEach((term) => {
let [type, period] = term.split(" ");
termInfo[type] = Number(period);
});
privacies.forEach((privacy, i) => {
let [day, type] = privacy.split(" ");
day = day.split(".").map(Number);
let dateCount = day[0] * 12 * 28 + day[1] * 28 + day[2] + termInfo[type] * 28;
if (dateCount <= todayCount) deleteTerm.push(i + 1);
});
return deleteTerm;
}