Maximum Frequency Stack
viaLeetCode
Implement a FreqStack that supports push(x) and pop(). pop() removes and returns the most frequent element; if several elements share the maximum frequency, it returns the one pushed most recently. Implement with a hash map of element->frequency and a map of frequency->stack of elements.
asked …