Hello everyone, today I am showing you a Stack question out of Cracking the Coding Interview. The question is 3.3 in the Stacks and Queues chapter. I discovered this implementation on-line and commented it for better understanding. The video below is also an explanation of the process.
The stack of plates question basically asks that, given a capacity, we stack plates up to that capacity. Once we’ve reached the capacity, we create a new stack and build up.
One Comment Add yours
at the function popAt, shouldn’t the comparison(2nd if statement) have index rather than index – 1