Algorithm/Problems
99클럽 코테 스터디 34일차 TIL + 구현
공부좀하시졍
2024. 12. 1. 10:08
https://school.programmers.co.kr/learn/courses/30/lessons/150370?language=python3
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
def solution(today, terms, privacies):
answer = []
d = {} # 약관 dict
today = list(map(int, today.split('.')))
# 일 단위로 변환
today = today[0]*12*28 + today[1]*28 + today[2]
for t in terms:
n,m = t.split()
d[n] = int(m) * 28 # 일 단위로 비교
for idx, p in enumerate(privacies):
date, info = p.split()
date = list(map(int, date.split('.')))
date = date[0]*12*28 + date[1]*28 + date[2]-1+d[info]
if date < today:
answer.append(idx+1)
return answer
- 일 단위로 변환하여 비교하는 방법이다.
- 모든 달은 28일까지 있기 때문에 28을 곱해 일단위로 변환하였다.
- date[2]-1을 한 이유는 개인정보 수집일자가 2021.05.02 이고 유효기간이 6달이면 2021.11.1일까지 보관 가능하기 때문이다.