Why Use Deque Library in Javascript instead of Array methods?


In the Breadth First Tree Traversal section, the solutions import the Deque class. I understand why a queue is necessary here, but can we not just use the shift and push methods that come out of the box for the Array class in javascript?

In an interview, it seems like it would always be better not to import unnecessary libraries.


1 Like

Yeah, in JS Array is a deque by default.