목록Data Engineering/Python (2)
공부하자
[코테] 프로그래머스 - 가장 큰 수 (Lv.2) Python 풀이
123456789101112131415161718192021from functools import cmp_to_key def solution(numbers): strNums = map(str, numbers) strNums = sorted(strNums, key=cmp_to_key(compare)) return ''.join(strNums) if strNums[0] != '0' else '0' def compare(strNum1, strNum2): num1 = strNum1 + strNum2 num2 = strNum2 + strNum1 if num1 num2: return 1 elif num2 num1: return -1 else:..
Data Engineering/Python
2025. 9. 18. 20:34
[코테] 프로그래머스 - 더 맵게 (Lv.2) Python 풀이
1234567891011121314151617181920212223import heapq def solution(scoville, K): answer = 0 heapq.heapify(scoville) while True: min1 = heapq.heappop(scoville) if min1 >= K: break elif len(scoville) == 0: answer = -1 break min2 = heapq.heappop(scoville) new_scoville = min1 + 2*min2 heapq.heappush(scoville, new..
Data Engineering/Python
2025. 9. 18. 20:29