Programming/프로그래머스

[프로그래머스] K번째수

pental 2020. 10. 10. 20:39

def solution(array, commands):
    result = []
    for i in commands:
        print(i)
        i_i = i[0]
        j_j = i[1]
        k_k = i[2]
        temp = array[int(i_i)-1:int(j_j)]
        temp = sorted(temp)
        result.append(temp[k_k-1])
    return result

그냥 슬라이싱을 이용하는 문제이다.

def solution(array, commands):
    return list(map(lambda x:sorted(array[x[0]-1:x[1]])[x[2]-1], commands))

이렇게도 할수 있다...