https://programmers.co.kr/learn/courses/30/lessons/42748
Code
1
2
def solution(array, commands):
return [sorted(array[i-1:j])[k-1] for i, j, k in commands]
Complexity
$O(mn log n)$
- $n$ = len(array)
- $(m, k)$ = commands.shape
PREVIOUSEtc
https://programmers.co.kr/learn/courses/30/lessons/42748
1
2
def solution(array, commands):
return [sorted(array[i-1:j])[k-1] for i, j, k in commands]
$O(mn log n)$