Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Created June 12, 2020 13:14
Show Gist options
  • Save DongguemYoo/ab217bb2f2fd93042b75dd278e03bda1 to your computer and use it in GitHub Desktop.
Save DongguemYoo/ab217bb2f2fd93042b75dd278e03bda1 to your computer and use it in GitHub Desktop.
[코딩테스트] k번째 수 python
def solution(array, commands):
answer = []
arr = []
for cnt in commands:
arr = []
for x in range(cnt[0] - 1, cnt[1]): //왜 cnt[1] -1 이 아니라 cnt[1]인지 이유
#range는 range(시작숫자,종료숫자)
#결과는 시작숫자부터 종료숫자 바로 앞 숫자까지 컬렉션을 만든다
#포인트는 종료숫자 포함이 아니라 바로 앞 숫자까지를 만드는것이다
arr.append(array[x])
arr.sort()
print(cnt[2])
answer.append(arr[cnt[2] - 1])
return answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment