---
# System prepended metadata

title: 2374. Node With Highest Edge Score
tags: [Leetcode, Medium]

---

# 2374. Node With Highest Edge Score
###### tags: `Leetcode` `Medium`
Link: https://leetcode.com/problems/node-with-highest-edge-score/description/
## Code
```java=
class Solution {
    public int edgeScore(int[] edges) {
        Map<Integer, Long> map = new HashMap<>();
        long maxScore = 0;
        int ans = 0;
        for(int i=0; i<edges.length; i++){
            map.put(edges[i], map.getOrDefault(edges[i], 0L)+i);
            if(map.get(edges[i])>maxScore){
                maxScore = map.get(edges[i]);
                ans = edges[i];
            }
            else if(map.get(edges[i])==maxScore && edges[i]<ans) ans = edges[i];
        }
        return ans;
    }
}
```