Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ const __NOT_FOUND__ = 0
const __FOUND__ = 1

func freqQuery(queries [][]int32) []int32 {
data_map := make(map[int32]int32)
dataMap := make(map[int32]int32)
freq := make(map[int32]int32)
var result []int32

for _, query := range queries {
switch query[0] {
case __INSERT__:
if data_map[query[1]] == __INITIAL__ {
data_map[query[1]] = 1
if dataMap[query[1]] == __INITIAL__ {
dataMap[query[1]] = 1
} else {
freq[data_map[query[1]]]--
data_map[query[1]]++
freq[dataMap[query[1]]]--
dataMap[query[1]]++
}
freq[data_map[query[1]]]++
freq[dataMap[query[1]]]++
case __DELETE__:
if data_map[query[1]] > __INITIAL__ {
freq[data_map[query[1]]]--
data_map[query[1]]--
freq[data_map[query[1]]]++
if dataMap[query[1]] > __INITIAL__ {
freq[dataMap[query[1]]]--
dataMap[query[1]]--
freq[dataMap[query[1]]]++
}
case __SELECT__:
if freq[query[1]] > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func getMinimumCost(k int32, c []int32) int32 {
slices.Reverse(flowers)

total := int32(0)
k_customers := int(k)
kCustomers := int(k)

for i, flower_cost := range flowers {
var position = int32(i / k_customers)
var position = int32(i / kCustomers)
total += int32(position+1) * int32(flower_cost)
}

Expand Down