Skip to content

Commit d5d5813

Browse files
Merge pull request #224 from Coding-Crew-Forever/youbbin/algorithm
[2025년 7월 둘째주 /youbbin] 정렬
2 parents d3cfb1d + 92632cb commit d5d5813

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

youbbin/PGS_42748.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
3+
public class Solution {
4+
public int[] solution(int[] array, int[,] commands) {
5+
int n = commands.GetLength(0);
6+
int[] answer = new int[n];
7+
8+
for (int idx = 0; idx < n; idx++) {
9+
int i = commands[idx, 0];
10+
int j = commands[idx, 1];
11+
int k = commands[idx, 2];
12+
13+
int len = j - i + 1;
14+
int[] subArray = new int[len];
15+
Array.Copy(array, i - 1, subArray, 0, len);
16+
17+
// 정렬
18+
Array.Sort(subArray);
19+
20+
// k번째 원소
21+
answer[idx] = subArray[k - 1];
22+
}
23+
24+
return answer;
25+
}
26+
}

0 commit comments

Comments
 (0)