Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Instead of appending list at the beginning to reverse, why not use Stack instead...

Sheraz Khan

Oct 3, 2022

Instead of appending list at the beginning to reverse, why not use Stack instead?

1

0

Comments
Comments
Design Gurus
Design Gurus3 years ago

Why is it a problem? Appending nodes to the beginning of a linked-list is not efficient?

If we push to a stack, we still have to make a list in the end.

M
Mikhail Putilov3 years ago

I did not get why java implementation is not using deque as well. https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/ArrayDeque.html#addFirst (E) uses ...