首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Chapter 三 Stacks and Queues - 3.3

2012-07-27 
Chapter 3 Stacks and Queues - 3.3Problem 3.3: Imagine a (literal) stack of plates. If the stack get

Chapter 3 Stacks and Queues - 3.3
Problem 3.3: Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshold. Implement a data structure SetOfStacks that mimics this. SetOfStacks should be composed of several stacks, and should create a new stack once the previous one exceeds capacity. SetOfStacks.push() and SetOfStacks.pop() should behave identically to a single stack (that is, pop() should return the same values as it would if there were just a single stack).
FOLLOW UP
Implement a function popAt(int index) which performs a pop operation on a specific sub-stack.


It is a quite easy one. However, the requirement of follow up question is not clear and we should discuss details with interviewers.


热点排行