Approach hintTry it first, then revealHide
Keep a frequency count per value and a separate stack for every frequency level. A push adds the value to the stack of its new frequency, and a pop takes from the highest non-empty level.
Keep a frequency count per value and a separate stack for every frequency level. A push adds the value to the stack of its new frequency, and a pop takes from the highest non-empty level.