Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Based on the constraints, what is the maximum element that can possibly be popped?
Maintain whether elements are in or not in the set. How many elements do we consider?