Skip to content

Commit a3021f1

Browse files
committed
Node With Highest Edge Score / 기초
1 parent fbcf529 commit a3021f1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
for (let i = 0; i < n; i++) {
13+
if (scores[i] > maxScore) {
14+
maxScore = scores[i];
15+
maxNode = i;
16+
}
17+
}
18+
19+
return maxNode;
20+
}

0 commit comments

Comments
 (0)