반응형

 

 

 

 

 

** Python

 

import re
import operator
def solution(s):
    _dict = dict()
    numbers = list(map(int, re.sub('[{,}]', ' ', s).split()))
    for number in numbers:
        try:
             _dict[number] += 1
        except KeyError:
             _dict[number] = 1
    _sorted = sorted(_dict.items(), key = lambda x: x[1], reverse = True)
    return [x[0] for x in _sorted]

 

 

 

추천 1등 풀이

 

def solution(s):

    s = Counter(re.findall('\d+', s))
    return list(map(int, [k for k, v in sorted(s.items(), key=lambda x: x[1], reverse=True)]))

import re
from collections import Counter

 

 

ㄷㄷ..

반응형

+ Recent posts