๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/64065
ํ์ด
# ํ๋ก๊ทธ๋๋จธ์ค 2๋จ๊ณ - 2019 ์นด์นด์ค ๊ฐ๋ฐ์ ๊ฒจ์ธ ์ธํด์ญ - ํํ
def solution(s):
answer = []
s_list = list(map(int, s.replace("{", "").replace("}", "").split(",")))
number = {}
for i in s_list:
if i not in number:
number[i] = 1
else:
number[i] += 1
snum = sorted(number.items(), key=lambda x:x[1], reverse=True)
for k in snum:
answer.append(k[0])
return answer
solution("{{2},{2,1},{2,1,3},{2,1,3,4}}")