fork download
  1. def max_weight_node(arr):
  2. score = collections.defaultdict(int)
  3. for i, e in enumerate(arr):
  4. if e ==-1: continue
  5. score[e] += i
  6. return max(score, key=lambda x: (score[x], x))
Success #stdin #stdout 0.04s 9684KB
stdin
23
4 4 1 4 13 8 8 8 0 8 14 9 15 11 -1 10 15 22 22 22 22 22 21
stdout
Standard output is empty