Merge branch 'master' of github.com:krahets/hello-algo

This commit is contained in:
Yudong Jin
2023-01-15 23:33:05 +08:00
3 changed files with 3 additions and 1 deletions

View File

@@ -98,6 +98,7 @@ func (h *maxHeap) poll() any {
// 判空处理
if h.isEmpty() {
fmt.Println("error")
return nil
}
// 交换根结点与最右叶结点(即交换首元素与尾元素)
h.swap(0, h.size()-1)