const changeToDate = (year, month, date) => {
return +year * 12 * 28 + +month * 28 + +date;
};
function solution(today, terms, privacies) {
var answer = [];
const termsObj = {};
for (const info of terms) {
const [type, month] = info.split(' ');
termsObj[type] = changeToDate(0, month, 0);
}
const todayDate = changeToDate(...today.split('.'));
for (let i = 0; i < privacies.length; i++) {
const [date, type] = privacies[i].split(' ');
const dueDate = changeToDate(...date.split('.')) + termsObj[type] - 1;
if (todayDate > dueDate) answer.push(i + 1);
}
return answer;
}
개인적으로 제대로 풀고 싶었는데,,,, 내일이 기말이라 벼락치기하느라 제대로 못 풀었다,,ㅠ (변명일수도)
풀이 코드를 보고 해결한 대신, 기말 이후에 다시 한 번 더 풀어볼 예정!