[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค-Lv1] K๋ฒˆ์งธ์ˆ˜ / Python

๐Ÿ“š Problem Solving/Programmers

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - K๋ฒˆ์งธ์ˆ˜

[1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3]

programmers.co.kr

import sys

input = sys.stdin.readline
n = int(input())
array = list(map(int, input().split()))
commands = [list(map(int, input().split())) for _ in range(n)]


def solution(array, commands):
    answer = []
    for i in commands:
        temp = array[i[0] - 1 : i[1]]
        temp.sort()
        answer.append(temp[i[2] - 1])
    return answer


print(solution(array, commands))

 

ํ•ด์„ค

์ฃผ์–ด์ง„ ๋ฒ”์œ„๋กœ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ž˜๋ผ ๋‹ต์„ ์ถ”์ถœํ•œ๋‹ค.