Skip to content

Commit 986ae4a

Browse files
committed
Ranking / 기초
1 parent 5898301 commit 986ae4a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tkddbs587/Hash/Ranking.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function solution(score) {
2+
// 1. score의 평균 점수를 구한다.
3+
let avg = score.map((v) => (v[0] + v[1]) / 2);
4+
5+
// 2. avg를 내림차순으로 정렬한 배열 sort를 선언한다.
6+
let sorted = avg.slice().sort((a, b) => b - a);
7+
8+
// 3. avg의 요소와 동일한 sorted 배열의 index 값에 1을 더한다.
9+
return avg.map((v) => sorted.indexOf(v) + 1);
10+
}

0 commit comments

Comments
 (0)