https://programmers.co.kr/learn/courses/30/lessons/72411
from itertools import combinations
def solution(orders, course):
answer = []
for i in course:
count = dict()
for order in orders:
for combi in combinations(order, i):
combi = tuple(sorted(combi))
if combi not in count:
count[combi] = 0
count[combi] += 1
if not count:
continue
max_count = max(count.values())
if max_count < 2:
continue
for key in count:
if count[key] == max_count:
answer.append(''.join(key))
answer.sort()
return answer