Tournament Winner

서재환·2023년 2월 6일
0

AlgoExpert

목록 보기
1/1

def tournamentWinner(competitions, results):
    # Write your code here.
    dic = {}
    for i in range(len(results)):
        index = None
        winning_team = results[i]
        if winning_team == 0:
            index = 1
        else:
            index = 0
        winner = competitions[i][index]
        if winner not in dic:
            dic[winner] = 3
        else:
            dic[winner] += 3
    res = sorted(dic.items(), key = lambda item: item[1], reverse=True)
    
    return res[0][0]

0개의 댓글