문제 설명

나의 풀이:

import numpy as np
def solution(id_list, report, k):
    answer = [0]*len(id_list)
    user =  [[0] * len(id_list) for i in range(len(id_list))]
    check_list = [0]*len(id_list)
    
    for i in range(0,len(report)):
        a = report[i].split()
        user[id_list.index(a[0])][id_list.index(a[1])] = 1

    for i in range(0, len(id_list)):
        for j in range(0, len(id_list)):
            check_list[i] += user[j][i]
            if check_list[i] >= k:
                for o in range(0, len(id_list)):
                    if user[o][i] == 1:
                        answer[o] += 1
                break        

    #print(answer)
    return answer

#id_list = ["con", "ryan"]
#report = ["ryan con", "ryan con", "ryan con", "ryan con"]

id_list = ["muzi", "frodo", "apeach", "neo"]
report = ["muzi frodo","apeach frodo","frodo neo","muzi neo","apeach muzi"]

solution(id_list, report, 2)

다른 사람의 풀이 :

Untitled

구글링 한거