-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathranking.js
More file actions
29 lines (26 loc) Β· 704 Bytes
/
Copy pathranking.js
File metadata and controls
29 lines (26 loc) Β· 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @desc problem : λ±μ ꡬνκΈ°
* @desc site : Olympiad
* @desc level: 2
* @desc problem : μ΄μ€ μν
*/
/**
* Solution
* @param {array} score: μ μ λ°°μ΄
*/
function solution(score) {
const rankArray = [];
score.forEach(function (item, index, array) {
let rank = array.length;
//μμ μ λ±μ λΉκ΅ (μμ μ μΈν μ μμμ λμ λλ§λ€ 1μ© μ€μ)
for (let i = 0; i < array.length; i++) {
if (index !== i && item >= array[i]) {
rank--;
}
}
rankArray.push(rank);
});
return rankArray;
}
const answer = solution([87, 89, 92, 100, 76]);
console.log(answer); //4 3 2 1 5