๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Algorithm/Programmers

[Programmers] ์‹คํŒจ์œจ

 

 

 

 

๋‚˜์˜ ์ฝ”๋“œ 

 

def solution(N, stages):
    arr = []
    hash = {}
    answer = []
    stages.sort(reverse=False)
    
    for i in range(1,N+1):
        arr.append(i)
    
    for l in arr:
        if l in stages:
            hash[l] = stages.count(l)/len(stages[stages.index(l):])
        
        else:
            hash[l] = 0
    
    hash = sorted(hash.items(), key = lambda x: x[1], reverse=True)
    
    for i in range(len(hash)):
        answer.append(hash[i][0])
    return answer

 

 

 

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์‹คํŒจ์œจ

์‹คํŒจ์œจ ์Šˆํผ ๊ฒŒ์ž„ ๊ฐœ๋ฐœ์ž ์˜ค๋ ๋ฆฌ๋Š” ํฐ ๊ณ ๋ฏผ์— ๋น ์กŒ๋‹ค. ๊ทธ๋…€๊ฐ€ ๋งŒ๋“  ํ”„๋žœ์ฆˆ ์˜ค์ฒœ์„ฑ์ด ๋Œ€์„ฑ๊ณต์„ ๊ฑฐ๋’€์ง€๋งŒ, ์š”์ฆ˜ ์‹ ๊ทœ ์‚ฌ์šฉ์ž์˜ ์ˆ˜๊ฐ€ ๊ธ‰๊ฐํ•œ ๊ฒƒ์ด๋‹ค. ์›์ธ์€ ์‹ ๊ทœ ์‚ฌ์šฉ์ž์™€ ๊ธฐ์กด ์‚ฌ์šฉ์ž ์‚ฌ์ด์— ์Šค

programmers.co.kr