895. Maximum Frequency Stack

Practice Maximum Frequency Stack for free on NudgeCode: Hard, Stack pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Design a stack-like structure where pop removes the most frequent value.

Each test is a list of operations and their arguments; the expected output lists what each call returns (null for calls that return nothing).

Example

["FreqStack","push","push","push","push","pop","pop"]
[[],[4],[7],[4],[7],[],[]]
->  [null,null,null,null,null,7,4]

Constraints