Skip to content

Commit 5898301

Browse files
committed
Set_treatment_order / 기초
1 parent e2795a6 commit 5898301

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function solution(emergency) {
2+
let sorted = [...emergency].sort((a, b) => b - a); // 배열 내림차순 정렬
3+
4+
return emergency.map((v) => sorted.indexOf(v) + 1);
5+
// 기존 배열의 각 요소를 내림차순 정렬된 배열에 매칭되는 요소로 접근하여 index + 1 로 순서대로 순위 매기고 map() 메서드를 통해 순위가 담긴 새 배열 반환
6+
}

0 commit comments

Comments
 (0)