Unofficial C Solution to Problem 3.3 in Cracking the Coding Interview (5th Edition)

10 Oct

The first part of this question is easy: use a set of stacks to mimic a single stack. In the second part, we need to implement a new method as popAt(int index) to make a pop operation on a specific sub-stack. In our solution, we deploy a lazy-defragment method. We allow some sub-stacks not being full after calling popAt. And only when more free space is need (in push operation), we try defragment to eliminate fragment inside each sub-stacks.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!