프로그래머스 1단계 "K번째 수"

sanha_OvO·2021년 6월 8일
0

Algorithm

목록 보기
42/84

문제

프로그래머스 K번째 수


풀이

슬라이실을 통해 리스트를 잘라주고 sorted()를 이용해 정렬하면 되는 쉬운 문제.


Python 코드

def solution(array, commands):
    answer = []
    for a in commands:
      i = a[0]
      j = a[1]
      k = a[2]
      tmp = sorted(array[i-1:j])
      answer.append(tmp[k-1])
    return answer
profile
Web Developer / Composer

0개의 댓글