DHistory
[Programmers] Level 1 - 개인정보 수집 유효기간 본문
문제
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이
DAY = 28
def solution(today, terms, privacies):
    answer = []
    # 현재 날짜를 일로 변경
    currentDays = calcuateToDays(today)
    # 각 약관 종류 별 만료일자
    expiredDays = {}
    for term in terms:
        termType, expirationPeriod = term.split()
        expiredDays[termType] = int(expirationPeriod) * DAY
        
    # 각 개인정보 수집 일자 만료 확인
    for i in range(len(privacies)):
        date, termType = privacies[i].split()
        privacyDays = calcuateToDays(date)
        if privacyDays + expiredDays[termType] - 1 < currentDays:
            answer.append(i + 1)
    return answer
def calcuateToDays(date: str):
    year, month, day = map(int, date.split("."))
    return year * 12 * DAY + month * DAY + day
채점 결과

'Computer Science > Algorithm' 카테고리의 다른 글
| [Programmers] Level 1 - 가장 가까운 같은 글자 (0) | 2023.07.03 | 
|---|---|
| [Programmers] Level 1 - 크기가 작은 부분 문자열 (0) | 2023.07.03 | 
| [Programmers] Level 1 - 둘만의 암호 (0) | 2023.06.28 | 
| [Programmers] Level 1 - 카드 뭉치 (0) | 2023.06.18 | 
| [Programmers] Level 1 - 대충 만든 자판 (0) | 2023.06.15 |