MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / push

Method push

python/0895-maximum-frequency-stack.py:7–13  ·  view source on GitHub ↗
(self, val: int)

Source from the content-addressed store, hash-verified

5 self.stacks = {}
6
7 def push(self, val: int) -> None:
8 valCnt = 1 + self.cnt.get(val, 0)
9 self.cnt[val] = valCnt
10 if valCnt > self.maxCnt:
11 self.maxCnt = valCnt
12 self.stacks[valCnt] = []
13 self.stacks[valCnt].append(val)
14
15 def pop(self) -> int:
16 res = self.stacks[self.maxCnt].pop()

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected