99클럽 코테 스터디 34일차 TIL + 구현

17__COLIN·2024년 11월 30일

99클럽

목록 보기
33/34
post-thumbnail

개인정보 수집 유효기간

코드

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;
}

개인적으로 제대로 풀고 싶었는데,,,, 내일이 기말이라 벼락치기하느라 제대로 못 풀었다,,ㅠ (변명일수도)

풀이 코드를 보고 해결한 대신, 기말 이후에 다시 한 번 더 풀어볼 예정!

profile
조금씩 꾸준히

0개의 댓글