Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d914d33

Browse files
chaerin-devprove-ability
authored andcommitted
Update K번째수.js
1 parent 26801b4 commit d914d33

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎level-1/K번째수.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,18 @@ function solution(array, commands) {
4545
}
4646
return answer;
4747
}
48+
49+
// 정답 5 - chaerin-dev
50+
function solution(array, commands) {
51+
let t = commands.length;
52+
let answer = [];
53+
while (t--) {
54+
let command = commands.shift();
55+
answer.push(
56+
array.slice(command[0] - 1, command[1]).sort((a, b) => a - b)[
57+
command[2] - 1
58+
]
59+
);
60+
}
61+
return answer;
62+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /