def solution(id_list, report, k):
    #신고자 배열 인덱스로 파악
    hate_list = [[] for i in range(len(id_list))]
    #신고횟수 딕셔너리 초기화
    hate_dic = {}
    answer = []
    for i in range(len(id_list)):
        answer.append(0)
    for i in id_list:
        hate_dic[i] = 0
        
    for i in range(len(report)):
        temp = report[i].split()
        id, hate = temp[0], temp[1]
        index = id_list.index(id)
        #시간 단축가능, set으로 변경시
        if hate not in hate_list[index]:
            hate_list[index].append(hate) 
            hate_dic[hate] += 1
    stop = [key for key, value in hate_dic.items() if value >= k]       
    #print(hate_dic)
    #print(stop)   
    #print(hate_list)
    
    for i in range(len(hate_list)):
        for j in hate_list[i]:
            if j in stop:
                answer[i] += 1
                
    return answer

Untitled

Untitled

Untitled