We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fbcf529 commit a3021f1Copy full SHA for a3021f1
JooKangSan/[week7]Graph/Node_With_Highest_Edge_Score.js
@@ -0,0 +1,20 @@
1
+function edgeScore(edges) {
2
+ const n = edges.length;
3
+ const scores = new Array(n).fill(0);
4
+
5
+ for (let i = 0; i < n; i++) {
6
+ scores[edges[i]] += i;
7
+ }
8
9
+ let maxScore = 0;
10
+ let maxNode = 0;
11
12
13
+ if (scores[i] > maxScore) {
14
+ maxScore = scores[i];
15
+ maxNode = i;
16
17
18
19
+ return maxNode;
20
+}
0 commit comments