Grokking Data Structures & Algorithms for Coding Interviews
0% completed
Solution: Implement Stack using Queues
.....
.....
.....
Like the course? Get enrolled and start learning!
A
Anonymous
· 2 years ago
The solution says that the time comp for the pop() operation is O(1). but Javascript implementation uses shift() which is O(n) in itself. Is there any way to handle this? or do we have no other choice?
A
Anonymous
· 3 years ago
Why is it even necessary to swap queues? Won't the main queue always be empty? i just did a
main = aux;
aux = new LinkedList<Integer>();
and solution was accepted
Show 1 reply
A
Anonymous
· 3 years ago
In the pop() method, the solution should check to see if the queue is empty before popping to prevent queue underflow.
Show 1 reply
Reading Progress
0%