mirror of
https://github.com/krahets/hello-algo.git
synced 2025-02-03 07:01:55 +08:00
Merge branch 'master' of github.com:krahets/hello-algo
This commit is contained in:
commit
b716359c99
@ -98,6 +98,7 @@ func (h *maxHeap) poll() any {
|
|||||||
// 判空处理
|
// 判空处理
|
||||||
if h.isEmpty() {
|
if h.isEmpty() {
|
||||||
fmt.Println("error")
|
fmt.Println("error")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
// 交换根结点与最右叶结点(即交换首元素与尾元素)
|
// 交换根结点与最右叶结点(即交换首元素与尾元素)
|
||||||
h.swap(0, h.size()-1)
|
h.swap(0, h.size()-1)
|
||||||
|
@ -606,6 +606,7 @@ comments: true
|
|||||||
// 判空处理
|
// 判空处理
|
||||||
if h.isEmpty() {
|
if h.isEmpty() {
|
||||||
fmt.Println("error")
|
fmt.Println("error")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
// 交换根结点与最右叶结点(即交换首元素与尾元素)
|
// 交换根结点与最右叶结点(即交换首元素与尾元素)
|
||||||
h.swap(0, h.size()-1)
|
h.swap(0, h.size()-1)
|
||||||
|
@ -490,7 +490,7 @@ comments: true
|
|||||||
func medianThree(nums []int, left, mid, right int) int {
|
func medianThree(nums []int, left, mid, right int) int {
|
||||||
if (nums[left] < nums[mid]) != (nums[left] < nums[right]) {
|
if (nums[left] < nums[mid]) != (nums[left] < nums[right]) {
|
||||||
return left
|
return left
|
||||||
} else if (nums[mid] < nums[left]) != (nums[mid] > nums[right]) {
|
} else if (nums[mid] > nums[left]) != (nums[mid] > nums[right]) {
|
||||||
return mid
|
return mid
|
||||||
}
|
}
|
||||||
return right
|
return right
|
||||||
|
Loading…
Reference in New Issue
Block a user