Programming Question

Question: Write a program to sort a stack such that the smallest items are on the top. You can use an additional temporary stack, but you may not copy the elements into any other data structure (such as an array). The stack supports the following operations: push, pop, peek, and isEmpty.

From: Cracking the Coding Interview [McDowell]

Subject: Stacks and Queues

Load Another Question


Select a Subject