MCPcopy
hub / github.com/qiyuangong/leetcode / next

Method next

python/346_Moving_Average_from_Data_Stream.py:12–20  ·  view source on GitHub ↗

:type val: int :rtype: float

(self, val)

Source from the content-addressed store, hash-verified

10
11
12 def next(self, val):
13 """
14 :type val: int
15 :rtype: float
16 """
17 if len(self.curr_range) == self.size:
18 self.curr_range.pop(0)
19 self.curr_range.append(val)
20 return sum(self.curr_range) * 1.0 / len(self.curr_range)
21
22
23

Callers 1

Calls 1

popMethod · 0.45

Tested by

no test coverage detected