728x90 Collections1 [ Python ] Collections - Counter, defaultdict 프로그래머스에서 숫자짝꿍 문제를 해결하고 다른 사람들의 풀이를 봤는데 처음 들어보는 Collection 패키지의 Counter와 defaultdict 객체를 사용한 풀이들이 눈에 보였다. # 이건 내 풀이 def solution(X, Y): nums = [] for n in set(X) & set(Y) : for i in range(min(X.count(n), Y.count(n))) : nums.append(n) if nums == [] : return "-1" else : if max([n != "0" for n in nums]) == 0 : return "0" return "".join(sorted(nums, reverse=True)) # 다른 사람의 풀이 from collections import .. 2023. 1. 23. 이전 1 다음 728x90