๋์ ์ฝ๋
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
'Algorithm > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Programmers] ์์ฅ (0) | 2022.05.18 |
---|---|
[Programmers] K๋ฒ์งธ ์ (0) | 2022.05.07 |
[Programmers] ๋ชจ์๊ณ ์ฌ (0) | 2022.05.05 |
[Programmers] JadenCase ๋ฌธ์์ด ๋ง๋ค๊ธฐ (0) | 2022.05.04 |
[Programmers] ์ซ์์ ํํ (0) | 2022.05.04 |