2. 풀이
from collections import Counter
from itertools import combinations
def solution(orders, course):
result = []
orders = [list(sorted(order)) for order in orders]
for c in course:
counter = Counter()
for order in orders:
for case in combinations(order, c):
counter[case] += 1
if not counter:
continue
mostCommon = counter.most_common()
frequency = mostCommon[0][1]
if frequency == 1:
continue
for key, count in counter.most_common():
if frequency==count:
result.append("".join(key))
return sorted(result)
Leave a comment