Update the section of heap.

This commit is contained in:
krahets
2023-05-25 20:25:19 +08:00
parent b9178bc7d6
commit 11c835d79c
36 changed files with 22 additions and 24 deletions

View File

@ -35,8 +35,7 @@ class MaxHeap:
def swap(self, i: int, j: int):
"""交换元素"""
a, b = self.max_heap[i], self.max_heap[j]
self.max_heap[i], self.max_heap[j] = b, a
self.max_heap[i], self.max_heap[j] = self.max_heap[j], self.max_heap[i]
def size(self) -> int:
"""获取堆大小"""