[Programmers] μ€ν¨μ¨
Updated:
μμ£Όνμ§ λͺ»ν μ μ
μ€ν¨μ¨ μ ν΄λ¦νλ©΄ λ°λ‘ μ΄λνλ€.
λ¬Έμ μμ μ€λͺ ν΄μ£Όλ μ€ν¨μ¨μ λ μλΏκ² μ μν΄λ³΄μλ©΄
μ€ν¨μ¨ = nth Stageμ μλ μ¬λ μ / nth Stage μ΄μμ μλ μ¬λ μ λΌκ³ ν μ μλ€.
return ν΄μΌ ν κ°μ μ€ν¨μ¨μ κΈ°μ€μΌλ‘ stage λ₯Ό λ΄λ¦Όμ°¨μ μ λ ¬νμ¬ μΆλ ₯νλ©΄ λλ€.
μ€ν¨μ¨μ΄ κ°μ κ²½μ° μμ stage λ¨Όμ μ€λ©΄ λλ€ !
μ°μ dict μ key κ°μ stage, value κ°μ μ€ν¨μ¨λ‘ μ μ₯μ ν ν value κ°μ κΈ°μ€μΌλ‘ λ΄λ¦Όμ°¨μ μ λ ¬μ νλ€.
import operator
def solution(N, stages):
answer = []
temp = dict()
for i in range(N):
curStage = 0
overStage = 0
for j in stages:
if i+1 == j:
curStage += 1
if i+1 <= j:
overStage += 1
if curStage == 0 or overStage == 0:
temp[i+1] = 0
else:
temp[i+1] = curStage / overStage
sTemp = sorted(temp.items(), key=operator.itemgetter(1), reverse=True)
for cur in sTemp:
answer.append(cur[0])
return answer
μμ§ λ€λ₯Έ μ¬λμ νμ΄λ λ³΄μ§ μμλλ° λ± λ΄λ κ°λ¨νκ³ μ§§μ μ½λκ° μμ² λ§μλ€..
μΌλ₯Έ κ°μ λ°°μμΌκ² λ€!
Leave a comment