feat(go): support new features with go code (#565)

* feat(go): support hash map chaining

* feat(go): support hash map open address

* feat(go): support simple hash

* feat(go): support top k heap

* feat(go): support subset sum I

* feat(go): support subset sum native

* feat(go): support subset sum II

* fix(go): fix some problem
This commit is contained in:
Reanon
2023-06-25 20:51:31 +08:00
committed by GitHub
parent efc1c2f49f
commit e4ba690005
10 changed files with 666 additions and 13 deletions
+11
View File
@@ -7,6 +7,7 @@ package chapter_heap
import (
"container/heap"
"fmt"
"strconv"
"testing"
. "github.com/krahets/hello-algo/pkg"
@@ -88,3 +89,13 @@ func TestMyHeap(t *testing.T) {
isEmpty := maxHeap.isEmpty()
fmt.Printf("\n堆是否为空 %t\n", isEmpty)
}
func TestTopKHeap(t *testing.T) {
/* 初始化堆 */
// 初始化大顶堆
nums := []int{1, 7, 6, 3, 2}
k := 3
res := topKHeap(nums, k)
fmt.Printf("最大的 " + strconv.Itoa(k) + " 个元素为")
PrintHeap(*res)
}