Notice
Recent Posts
Recent Comments
ยซ   2024/09   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags more
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

๐ŸŒฒ์ž๋ผ๋‚˜๋Š”์ฒญ๋…„

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] K ๋ฒˆ์งธ ์ˆ˜, python ๋ณธ๋ฌธ

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œํ’€์ด

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] K ๋ฒˆ์งธ ์ˆ˜, python

JihyunLee 2019. 10. 31. 17:31
๋ฐ˜์‘ํ˜•

K๋ฒˆ์งธ ์ˆ˜


ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์—์„œ K ๋ฒˆ์งธ์ˆ˜๋ฅผ python ์œผ๋กœ ํ’€์–ด๋ณด์•˜๋‹ค.

 

๋‚œ์ด๋„ : ํ•˜

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
def solution(array, commands):
    answer = []
    for ijk in commands:
        i = ijk[0]
        j = ijk[1]
        k = ijk[2]
 
        cut_array = array[i-1:j]
        print(cut_array)
        cut_array.sort()
        answer.append(cut_array[k-1])
    
    return answer
cs
๋ฐ˜์‘ํ˜•