코딩테스트

프로그래머스 K번째수

박준희 2021. 11. 11. 19:34

https://programmers.co.kr/learn/courses/30/lessons/42748

 

코딩테스트 연습 - K번째수

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

programmers.co.kr

 

 

def solution(array, commands):
    answer = []
    for x in commands:
        tmp = array[x[0]-1:x[1]]
        tmp.sort()
        answer.append(tmp[x[2]-1])
    return answer