Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Rishi Jatia
Unnecessary to swap queues

Rishi Jatia

Apr 15, 2024

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

0

0

Comments
Comments
Ahmed Yarub Hani Al Nuaimi
Ahmed Yarub Hani Al Nuaimia year ago

To avoid instantiating a new object and garbage-collecting the unused one.

On this page