func solution(_ array:[Int], _ commands:[[Int]]) -> [Int] {
var answer = [Int]()
for command in commands {
let i = command[0] - 1
let j = command[1] - 1
let k = command[2] - 1
let num = array[i...j].sorted()[k]
answer.append(num)
}
return answer
}
func solution(_ array:[Int], _ commands:[[Int]]) -> [Int] {
return commands.map({(key) in
return array[(key[0]-1)...(key[1]-1)].sorted()[key[2]-1]
})
}