프로그래머스 - 메뉴 리뉴얼


프로그래머스 - 메뉴 리뉴얼

123456789101112131415161718192021222324252627from itertools import combinationsfrom collections import defaultdict def solution(orders, course): answer = [] for c in course: tmp2 = [] for o in orders: tmp = combinations(sorted(o),c) tmp2 += tmp menus = defaultdict(int) for t in tmp2: menus["".join(t)] += 1 if not menus: continue cnt = max(menus.values()) if cnt <= 1: continue for i,j in menus.items(): if j == cnt: answer.append("".join(i)) return sorted(answer)cs course를 바탕으로 order에 들어 있는 값으로 조합 생성값과 빈도수를 menus에 저장각 코스의 수당 최대 빈도의 요리를 찾는다(1명이하의..........



원문링크 : 프로그래머스 - 메뉴 리뉴얼