개발/PS

프로그래머스 Lv1 정렬 k번째 수 (파이썬)

유훈 | Yuhun 2021. 12. 30. 03:24
반응형

풀이

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

슬라이싱 해주고 문자열을 뽑아 answer에 추가하는 것을 commands의 수 만큼 하면 됩니다.

반응형