Problem 895 · Hard

Maximum Frequency Stack

Keep one stack per frequency level; pop from the highest level, which preserves recency among ties.

Open the interactive visualisation