-
[Programmers] 2021 KAKAO BLIND RECRUITMENT: 메뉴 리뉴얼(Python)Problem Solving/Programmers 2021. 6. 8. 03:19
https://programmers.co.kr/learn/courses/30/lessons/72411
from itertools import combinations def solution(orders, course): answer = [] orderset = [] for o in orders: orderset.append(set(o)) comb=set() for o in orders: for num in course: if num>len(o):break li = list(combinations(sorted(list(o)),num)) for l in li: comb.add(l) can = [[] for _ in range(11)] for i in comb: cnt = 0 for o in orderset: if len(i) > len(o):continue if len(set(i) - o)==0: cnt+=1 s = "".join(sorted(list(i))) if cnt>=2: can[len(s)].append([s,cnt]) for i in range(len(can)): if len(can[i])==0:continue can[i].sort(key=lambda x:x[1], reverse=True) for c in can[i]: if c[1]==can[i][0][1]:answer.append(c[0]) return sorted(answer)
'Problem Solving > Programmers' 카테고리의 다른 글
[Programmers]2021 KAKAO BLIND RECRUITMENT: 카드 짝 맞추기(Python)/BFS (0) 2021.06.11 [Programmers] 2020 KAKAO BLIND RECRUITMENT: 기둥과 보 설치(Python) (0) 2021.06.09 [Programmers] 2020 카카오 인턴십: 동굴 탐험(C++) / Topological Sort (1) 2021.05.08 [Programmers]2021 KAKAO BLIND RECRUITMENT: 순위 검색(Python) (2) 2021.05.06 [Programmers] 2021 KAKAO BLIND RECRUITMENT: 합승 택시 요금(C++) / FloydWashall (3) 2021.04.13