Check if a queue can be sorted in another queue using a stack | GeeksforGeeks

preview_player
Показать описание

This video is contributed by Parul Shandilya.

Please Like, Comment and Share the Video among your friends.

Install our Android App:

If you wish, translate into local language and help us reach millions of other geeks:

Follow us on Facebook:

And Twitter:

Also, Subscribe if you haven't already! :)
Рекомендации по теме
Комментарии
Автор

hard coding check to 1 does not seem generic...this algorithm should be applicable to any set of natural random numbers..

phaniauce
Автор

Will it work if the input queue is {6, 3, 5, 1, 4, 2}. There may require swapping elements inside stack to maintain order?

jeffiedward
Автор

What about if the elements are random integers than this algorithm won't

rishisharma