[programmers] k번째수

데린이·2022년 4월 8일
0

리스트의 숫자 배열 정렬 및 인덱스를 활용하여 숫자 추출
https://programmers.co.kr/learn/courses/30/lessons/42748

22-04-08 code

def solution(array, commands):

    return [sorted(array[i-1:j])[k-1] for i,j,k in commands]

Tip
1. map을 활용하자. list(map(function, array))

22-04-23 code

def solution(array, commands):
    
    return list(map(lambda x : sorted(array[(x[0]-1):(x[1])])[x[2]-1],commands))
profile
취뽀를 기원하는 취준생입니다!

0개의 댓글