๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Algorithm/Programmers

[Programmers] K๋ฒˆ์งธ ์ˆ˜

 

 

๋‚˜์˜ ์ฝ”๋“œ 

 

def solution(array, commands):
    arr = []
    
    for i in range(len(commands)):
        num = array[commands[i][0]-1:commands[i][1]]
        num.sort(reverse=False)
        ans = num[commands[i][2]-1]
        arr.append(ans)
    return arr

 

 

 

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - K๋ฒˆ์งธ์ˆ˜

[1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3]

programmers.co.kr