Notice
Recent Posts
Recent Comments
Link
아는 만큼 보인다
[프로그래머스] K번째수 python3 본문
프로그래머스 K번째수 python3 문제 바로가기
코딩테스트 연습 - 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 command in commands:
start = command[0]-1 # 문제에서는 말 그대로 command[0]번째수 부터 끊는데, python에서는-1 해주어야.
end = command[1]
tmp = array[start:end] # array 끊은 것을 할당
tmp.sort() # sorting
answer.append(tmp[command[2]-1]) # start에서와 같은 이유로 -1
return answer
'알고리즘&자료구조 > 코딩테스트 연습' 카테고리의 다른 글
[프로그래머스] 로또의 최고 순위와 최저 순위 python3 (1) | 2022.06.16 |
---|---|
[프로그래머스] 숫자 문자열과 영단어 python3 (1) | 2022.06.11 |
[프로그래머스] H-index python3 (0) | 2022.06.11 |
[프로그래머스] 완주하지 못한 선수 python3 (0) | 2022.06.11 |
[프로그래머스] 신고결과 받기 python3 (0) | 2022.06.11 |