import Foundation
func solution(_ array:[Int], _ commands:[[Int]]) -> [Int] {
var arr = array
var arr2 = [Int]()
var result = [Int]()
for i in 0..<commands.count {
for _ in commands[i][0]...commands[i][1] {
let a = arr.remove(at: commands[i][0] - 1)
arr2.append(a)
}
arr2 = arr2.sorted()
result.append(arr2[commands[i][2] - 1])
arr = array
arr2 = [Int]()
}
return result
}
[Swift]프로그래머스 K번째 수
코딩테스트Swift카테고리의 다른글
[Swift] 프로그래머스 행렬 테두리 회전하기 (0) | 2022.03.27 |
---|---|
[Swift]프로그래머스 모의고사 (0) | 2021.09.21 |
[Swift]프로그래머스 기능개발 (0) | 2021.09.21 |
[Swift] 백준 2751 수 정렬하기 2 (0) | 2021.09.05 |
[Swift] 백준 5622 - 다이얼 (0) | 2021.08.21 |