1086. High Five
On This Page
class Solution:
def highFive(self, items: List[List[int]]) -> List[List[int]]:
d = defaultdict(list)
m = 0
for i, x in items:
d[i].append(x)
m = max(m, i)
res = []
for i in range(1, m + 1):
if xs := d[i]:
avg = sum(nlargest(5, xs)) // 5
res.append([i, avg])
return res