[프로그래머스] 추억 점수

Seohyun·2024년 8월 31일

알고리즘

목록 보기
26/36
def solution(name, yearning, photo):
    answer = []
    score = {}
    for p in photo:
        tot_score = 0
        for person in p:
            if person in name:
                tot_score += yearning[name.index(person)]
        answer.append(tot_score)
    return answer

전에 푼 문제에서 .index() 함수를 쓰니 시간 초과가 났는데 이번 문제의 각 배열들의 길이가 그리 길지 않아서 그냥 사용했다.

profile
Hail hamster

0개의 댓글