부분 배열을 만들어서 정렬하는 간단한 문제
import Foundation
func solution(_ array:[Int], _ commands:[[Int]]) -> [Int] {
var answers = [Int]()
for command in commands {
let (i, j, k) = (command[0]-1, command[1]-1, command[2]-1)
let splitedArray = Array(array[i...j]).sorted()
let answer = splitedArray[k]
answers.append(answer)
}
return answers
}