2374. Node With Highest Edge Score

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2374

class Solution:
    def edgeScore(self, edges: List[int]) -> int:
        cnt = Counter()
        for i, v in enumerate(edges):
            cnt[v] += i
        res = 0
        for i in range(len(edges)):
            if cnt[res] < cnt[i]:
                res = i
        return res