-
[Python] heapq maxheap 메서드 종류 및 사용알고리즘 2022. 6. 24. 17:57
import heapq
arr = [0,2,40,112,11,1]
heapq._heapify_max(arr); // max_heap 형태로 만들어줌
arr[0] 은 max 값. // 112
maxV = heapq._heapreplace_max(arr, value e.g.:120); // arr 에서 max 값을 삭제하고, value 를 넣어 max 힙으로 만듦
// maxV = 112, arr = [120, .....]
'알고리즘' 카테고리의 다른 글
[LeetCode] 11. Container With Most Water (0) 2022.06.25 [LeetCode] 1354. Construct Target Array With Multiple Sums (0) 2022.06.24 [LeetCode] 90. Subsets II (0) 2022.06.22 [LeetCode] 438. Find All Anagrams in a String (0) 2022.06.21 Manacher's Algorithm [가장 긴 펠렌드롬 찾기] (0) 2022.06.20