401 data structures and algorithms code challenges
Create a new class called pseudo queue. Class should function as a queue without using the existing Queue class. Utilize 2 Stack instances to create and manage the queue.
value into the PseudoQueue, using a first-in, first-out approach.
enqueue(value)
| Input | Args | Output |
|---|---|---|
| [10]->[15]->[20] | 5 | [5]->[10]->[15]->[20] |
| 5 | [5] |
dequeue()
| Input | Output | Internal State |
|---|---|---|
| [5]->[10]->[15]->[20] | 20 | [5]->[10]->[15] |
| [5]->[10]->[15] | 15 | [5]->[10] |
None
.enqueue is only concerned with the first in part of, “first in, first,” out so all i had to do was use a .push from the Stack class. Next I used a second stack to reverse my origional stack to .dequeue the first item pushed into my origional stack.