MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / subarraySum

Function subarraySum

tasks/560.go:9–19  ·  view source on GitHub ↗
(nums []int, k int)

Source from the content-addressed store, hash-verified

7}
8
9func subarraySum(nums []int, k int) int {
10 sumFreq := map[int]int{0: 1}
11 sum := 0
12 count := 0
13 for _, v := range nums {
14 sum += v
15 count += sumFreq[sum-k]
16 sumFreq[sum]++
17 }
18 return count
19}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected