def solution(array, commands):
answer = []
for command in commands:
i = command[0]
j = command[1]
k = command[2]
if i != j:
temp = sorted(array[i-1:j])[k-1]
answer.append(temp)
else:
temp = array[i-1]
answer.append(temp)
return answer
๋ค๋ฅธํ์ด
def solution(array, commands):
return list(map(lambda x:sorted(array[x[0]-1:x[1]])[x[2]-1], commands))
๋๋ค๋ฅธํ์ด
def solution(array, commands):
answer = [i for i in map(lambda x: sorted(array[x[0]-1:x[1]])[x[2]-1], commands)]
return answer
ํ์ด ๋๋ค ์ด์ฉํด์ ํ๋ ์ง์ง ์ฌํํ๊ณ ๊ฐ๋จํ๋ค..!
'๐ Python > ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์์ ํ์] ๋ชจ์๊ณ ์ฌ (0) | 2022.04.13 |
---|---|
[์ ๋ ฌ]H-index (0) | 2022.04.01 |
[์ ๋ ฌ]๊ฐ์ฅ ํฐ ์ (0) | 2022.03.31 |