Algorithm/Programmers

[Programmers] μ‹€νŒ¨μœ¨

Earth Wave 2022. 5. 7. 00:41

 

 

 

 

λ‚˜μ˜ μ½”λ“œ 

 

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