1 Star 0 Fork 0

catyMap/AlgorithmNote

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
topKFrequentII.go 537 Bytes
一键复制 编辑 原始数据 按行查看 历史
dogemap 提交于 2021-05-29 20:56 +08:00 . 添加二位数组前缀和题目
package main
import (
"container/heap"
"sort"
)
type HeapArr struct {
sort.IntSlice
}
func (h *HeapArr) Pop() interface{} {
n := len(h.IntSlice)
t := (h.IntSlice)[n -1]
h.IntSlice = (h.IntSlice)[:n-1]
return t
}
func (h *HeapArr) Push(node interface{}) {
h.IntSlice = append(h.IntSlice, node.(int))
}
// 小顶堆
func topKFrequent(words []string, k int) []string {
freqMap := make(map[string]int)
for _ , v := range words {
freqMap[v] ++
}
h := HeapArr{
make([]int,0 ,0),
}
heap.Init(&h)
}
func main() {
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dogemap/algorithm-note.git
git@gitee.com:dogemap/algorithm-note.git
dogemap
algorithm-note
AlgorithmNote
dc486f96f6c1

搜索帮助