728x90

나의 풀이
def solution(array, commands):
answer = []
for n in range(len(commands)):
i, j, k = commands
temp = list(array[i-1:j])
temp.sort()
answer.append(temp[k-1])
return answer
map과 lamda를 이용한 풀이
def solution(array, commands):
return list(map(lambda x:sorted(array[x[0]-1:x[1]])[x[2]-1], commands))
반응형
'Coding Test > Programmers' 카테고리의 다른 글
| [프로그래머스/파이썬] H-Index (0) | 2022.06.03 |
|---|---|
| [프로그래머스/파이썬] 가장 큰 수 (0) | 2022.06.03 |
| [프로그래머스/파이썬] 이중우선순위큐 (0) | 2022.06.03 |
| [프로그래머스/파이썬] 디스크 컨트롤러 (0) | 2022.06.03 |
| [프로그래머스/파이썬] 더 맵게 (0) | 2022.06.03 |