https://school.programmers.co.kr/learn/courses/30/lessons/42748
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
파이썬의 내장 메소드를 이용해 List를 자르고, 정렬해서 원하는 값을 출력했습니다.
def solution(array, commands):
answer = []
for command in commands:
start = command[0]
end = command[1]
target = command[2]
arr = array[start-1:end]
arr.sort()
answer.append(arr[target-1])
return answer
print(solution([1, 5, 2, 6, 3, 7, 4], [[2, 5, 3], [4, 4, 1], [1, 7, 3]]))
'🔍 알고리즘 > 프로그래머스 Python' 카테고리의 다른 글
[Python] 프로그래머스 42862. 체육복 (Lv.1) (0) | 2022.08.07 |
---|---|
[Python] 프로그래머스 42840. 모의고사 (Lv.1) (0) | 2022.08.07 |
[Python] 프로그래머스 1845.폰켓몬 (Lv.1) (0) | 2022.08.07 |
[Python] 프로그래머스 42627.디스크컨트롤러 (Lv.3) (0) | 2022.08.06 |
[Python] 프로그래머스 43162.네트워크 (Lv.3) (0) | 2022.08.06 |