Skip to content

Commit 7a6d155

Browse files
committed
Added comments
1 parent f87eb02 commit 7a6d155

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/main/java/com/ctci/stacksandqueues/QueueViaStacks.java

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.Stack;
55

66
/**
7+
* Implement a queue using two stacks. No other data structures to be used.
8+
*
79
* @author rampatra
810
* @since 2019-02-06
911
*/

src/main/java/com/ctci/stacksandqueues/SortStack.java

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import java.util.Stack;
55

66
/**
7+
* Write a program to sort a stack such that the smallest items are on the top. You can use an additional temporary
8+
* stack, but you may not copy the elements into any other data structure (such as an array). The stack supports the
9+
* following operations: push, pop, peek, and isEmpty.
10+
*
711
* @author rampatra
812
* @since 2019-02-08
913
*/

src/main/java/com/ctci/stacksandqueues/StackOfPlates.java

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
import java.util.Stack;
88

99
/**
10+
* Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we
11+
* would likely start a new stack when the previous stack exceeds some threshold. Implement a data structure
12+
* SetOfStacks that mimics this. SetOfStacks should be composed of several stacks and should create a new stack once
13+
* the previous one exceeds capacity. SetOfStacks.push() and SetOfStacks. pop() should behave identically to a single
14+
* stack (that is, pop() should return the same values as it would if there were just a single stack).
15+
*
1016
* @author rampatra
1117
* @since 2019-02-08
1218
*/

0 commit comments

Comments
 (0)