Tap here to switch tabs
Problem
Submissions

Problem: Node With Highest Edge Score

med
30 min
Try to solve the Node With Highest Edge Score problem.

Statement

You are given a directed graph with nn nodes labeled from 00 to n−1n - 1. The graph is represented by a 00 indexed integer array edges of length nn, where a directed edge exists from node i to node edges[i].

The edge score of a node is defined as the sum of the labels of all nodes that have a directed edge pointing to that node.

Return the node with the highest edge score. If multiple nodes have the same highest edge score, return the node with the smallest index.

Constraints:

  • n ==== edges.length

  • 2≤n≤1052 \leq n \leq 10^5

  • 0≤0 \leq edges[i] <n< n

  • edges[i] ≠\neq i

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Node With Highest Edge Score

med
30 min
Try to solve the Node With Highest Edge Score problem.

Statement

You are given a directed graph with nn nodes labeled from 00 to n−1n - 1. The graph is represented by a 00 indexed integer array edges of length nn, where a directed edge exists from node i to node edges[i].

The edge score of a node is defined as the sum of the labels of all nodes that have a directed edge pointing to that node.

Return the node with the highest edge score. If multiple nodes have the same highest edge score, return the node with the smallest index.

Constraints:

  • n ==== edges.length

  • 2≤n≤1052 \leq n \leq 10^5

  • 0≤0 \leq edges[i] <n< n

  • edges[i] ≠\neq i