728x90
반응형
import (
"sort"
)
func solution(array []int, commands [][]int) []int {
result := make([]int, len(commands))
for i := 0; i < len(commands); i++ {
arr := make([]int, len(array))
copy(arr, array)
arr = arr[commands[i][0] - 1 : commands[i][1]]
sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j]})
result[i] = arr[commands[i][2] -1]
}
return result
}
728x90
반응형
'프로그래머스 > LEVEL 1' 카테고리의 다른 글
서울에서 김서방 찾기 (2) | 2021.09.19 |
---|---|
1주차_부족한 금액 계산하기 (0) | 2021.09.19 |
약수의 개수와 덧셈 (0) | 2021.06.13 |
로또의 최고 순위와 최저 순위 (0) | 2021.05.09 |
x만큼 간격이 있는 n개의 숫자 (0) | 2021.03.07 |