728x90
반응형
문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/72411
풀이:
다른 분의 풀이를 참고했다... 맨 마지막 if 문땜에 어쩔수 없었다
from itertools import combinations
from collections import Counter
def solution(orders, course):
answer = []
for c in course:
temp = []
for order in orders:
combi = combinations(sorted(order), c)
temp += combi
counter = Counter(temp)
if len(counter) != 0 and max(counter.values()) != 1:
answer += [''.join(f) for f in counter if counter[f] == max(counter.values())]
return sorted(answer)
출처: https://ljhyunstory.tistory.com/19 [오늘도 컴돌이!:티스토리]
또 다른 풀이
참고 :https://www.youtube.com/watch?v=PnXovk2JtU4
반응형
댓글