MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / Constructor

Function Constructor

moving_average_from_data_stream_346/solution.go:10–16  ·  view source on GitHub ↗

** Initialize your data structure here. */

(size int)

Source from the content-addressed store, hash-verified

8
9/** Initialize your data structure here. */
10func Constructor(size int) MovingAverage {
11 return MovingAverage{
12 q: make([]int, 0),
13 size: size,
14 sum: 0,
15 }
16}
17
18func (this *MovingAverage) Next(val int) float64 {
19 if len(this.q) == this.size {

Callers 1

Calls

no outgoing calls

Tested by 1