일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- sql코테
- Python
- 자연어처리
- 슬라이딩윈도우
- 니트코드
- 파이썬
- gcp
- LeetCode
- 파이썬기초100제
- codeup
- nlp
- slidingwindow
- 파이썬알고리즘
- Python3
- 생성형AI
- 구글퀵랩
- GenAI
- Blazor
- Microsoft
- 리트코드
- 릿코드
- medium
- 투포인터
- 알고리즘
- two-pointer
- GenerativeAI
- 코드업
- dfs
- stratascratch
- SQL
- Today
- Total
목록힙알고리즘 (2)
Tech for good

Example 1:gifts = [25, 64, 9, 4, 100], k = 4[25, 64, 9, 4, 100]-> (1회) [25, 64, 9, 4, 10]-> (2회) [25, 8, 9, 4, 10]-> (3회) [5, 8, 9, 4, 10]-> (4회) [5, 8, 9, 4, 3] (floor or the square root - floor: 내림)5 + 8 + 9 + 4 + 3 = 29 Follow these steps:Pick the largest pile of gifts.Replace it with the floor of its square root.Repeat this for k seconds.🔧 Best Tool for This?We need to efficiently get the l..

class Solution: def maxProduct(self, nums: List[int]) -> int: # Convert to max-heap by pushing negative values max_heap = [-num for num in nums] heapq.heapify(max_heap) # Pop the two largest values first_max = -heapq.heappop(max_heap) second_max = -heapq.heappop(max_heap) return (first_max - 1) * (second_max - 1)