๋์ ์ฝ๋
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
'Algorithm > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Programmers] ํคํจ๋ ๋๋ฅด๊ธฐ (0) | 2022.05.19 |
---|---|
[Programmers] ์์ฅ (0) | 2022.05.18 |
[Programmers] ์คํจ์จ (0) | 2022.05.07 |
[Programmers] ๋ชจ์๊ณ ์ฌ (0) | 2022.05.05 |
[Programmers] JadenCase ๋ฌธ์์ด ๋ง๋ค๊ธฐ (0) | 2022.05.04 |