⚠️ 문제
https://school.programmers.co.kr/learn/courses/30/lessons/150370
🔐 풀이
약관의 유효기간은 약관의 종류별로 딕셔너리에 저장해두고,
"모든 달은 28일까지 있다고 가정한다"고 문제에 주어져있기 때문에 비교해야 하는 오늘 날짜와 개인정보의 보관 일자는 모두 일 수로 변경해서 비교해줍니다.
🧑🏻💻 코드
def solution(today, terms, privacies):
answer = []
term_dic = {}
today_year, today_month, today_date = map(int, today.split("."))
for term in terms:
c, m = term.split()
term_dic[c] = int(m)
for idx, privacy in enumerate(privacies):
year_month_date, case = privacy.split()
year, month, date = map(int, year_month_date.split("."))
today = today_year * 12 * 28 + today_month * 28 + today_date
expiration = year * 12 * 28 + month * 28 + date + term_dic[case] * 28 - 1
if today > expiration:
answer.append(idx+1)
return answer