Create Opportunities

[알고리즘] 개인정보 수집 유효기간 본문

알고리즘

[알고리즘] 개인정보 수집 유효기간

kimjaeyoon 2023. 3. 7. 15:55

List 형태로 주어진 term의 형태는 ['A 6', 'B 12', 'C 3'] 와 같은 형태이다. 이를 Dictionary로 아래와 같이 변환할 수 있다.

termsInfo = dict()
term = term.split()
termsInfo[term[0]] = int(term[1]) * 28   #(x28은 month to day를 위해서)
Lv. 1

def dateToDay(date):
    y, m, d = map(int, date.split("."))
    return (y * 12 * 28) + (m * 28) + d
    
def solution(today, terms, privacies):
    answer = []
    
    # today
    today = dateToDay(today)
    
    # terms
    termsInfo = dict()
    for term in terms:
        term = term.split()
        termsInfo[term[0]] = int(term[1]) * 28
    
    # privacies
    for i in range(len(privacies)):
        date, term = privacies[i].split()
        if dateToDay(date) + termsInfo[term] <= today:
            answer.append(i+1)
        
    return answer

'알고리즘' 카테고리의 다른 글

[알고리즘] 상담예약제, 티셔츠  (0) 2023.03.16
[알고리즘] Hash, Greedy, Sort  (0) 2023.03.10
[알고리즘] 뒤에 있는 큰 수 찾기  (0) 2023.03.06
[알고리즘] 둘만의 암호  (1) 2023.03.06
[알고리즘] 숫자 변환  (0) 2023.03.02