We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 81b4806 commit 05e4c2aCopy full SHA for 05e4c2a
Leetcode/0347.Top-K-Frequent-Elements/README.md
@@ -154,6 +154,9 @@ import (
154
155
// 方法一: 使用 PriorityQueue
156
// 時間複雜 O(Nlogk), 空間複雜 O(N)
157
+// 首先遍歷整個數組,並使用哈希表記錄每個數字出現的次數,並形成一個「出現次數數組」
158
+// 建立一個 PriortyQueue, 將「出現次數數組」丟進去
159
+// 在把 PriortyQueue pop的值丟到 result
160
func TopKFrequent(nums []int, k int) []int {
161
m := make(map[int]int)
162
for i := 0; i < len(nums); i++ {
Leetcode/0347.Top-K-Frequent-Elements/main.go
@@ -7,6 +7,9 @@ import (
7
8
9
10
11
12
13
14
15
0 commit comments