Skip to content

Instantly share code, notes, and snippets.

@svaza
Created August 14, 2022 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svaza/4e004b61e63bc3895b1ece4a139f2f90 to your computer and use it in GitHub Desktop.
Save svaza/4e004b61e63bc3895b1ece4a139f2f90 to your computer and use it in GitHub Desktop.
2374. Node With Highest Edge Score
public class Solution {
public int EdgeScore(int[] edges) {
long[] deg = new long[edges.Length];
long max = -1;
for(int i = 0; i < edges.Length; i++)
{
deg[edges[i]]+=i;
max = Math.Max(max, deg[edges[i]]);
}
for(int i = 0; i < deg.Length; i++)
{
if(deg[i] == max)
return i;
}
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment