135. Design a set of stacks that starts a new stack whenever the current one reaches capacity, but behaves like one stack.
MediumStacks
Technical
Show model answer
Keep a list of bounded stacks. Push goes to the last stack, or to a newly created stack if the last one is full. Pop removes from the last stack and discards that stack when it becomes empty. Both are O(1).
A follow-up `popAt(index)` pops from a specific inner stack. Either allow that stack to stay partially filled (O(1), but stacks are no longer all full), or roll over by shifting the bottom element of each later stack into the previous one to keep them compact, which costs O(total elements after index). Clarify which behaviour is expected.