mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 22:34:18 +08:00
Update the section of heap.
This commit is contained in:
@ -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:
|
||||
"""获取堆大小"""
|
||||
|
Reference in New Issue
Block a user