📌문제
https://programmers.co.kr/learn/courses/30/lessons/42748
🎖️난이도
Level 1
✔️풀이
# sol1
def solution(array, commands):
answer = []
for command in commands:
arr_tmp = array
arr_tmp = arr_tmp[command[0]-1:command[1]]
arr_tmp.sort()
answer.append(arr_tmp[command[2]-1])
return answer
# sol2) lambda
def solution(array, commands):
return list(map(lambda x:sorted(array[x[0]-1:x[1]])[x[2]-1], commands))
# sol3) 리스트 내포
def solution(array, commands):
return [sorted(array[x[0]-1:x[1]])[x[2]-1] for x in commands]
'[ 알고리즘 ] > Sort & Binary Search' 카테고리의 다른 글
[백준] 2110. 공유기 설치 (0) | 2022.06.30 |
---|---|
[백준] 1300. K번째 수 (0) | 2022.06.30 |
[백준] 10816. 숫자 카드 2 (0) | 2022.06.30 |
[프로그래머스] 입국심사 (0) | 2022.06.29 |
[프로그래머스] 가장 큰 수 (0) | 2022.06.29 |