Queue - Implement Queue using Stack | Code in Java

preview_player
Показать описание
Solution:
- We'll take two stacks
- For enqueue, we push element in Stack-1
- For dequeue, we pop all elements from stack1 & push to stack2 & then pop element from stack2
- Now for again dequeue, if size of stack 2 is not emepty then we remove element from stack

Do Watch video for more info

CHECK OUT CODING SIMPLIFIED

★☆★ VIEW THE BLOG POST: ★☆★

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

★☆★ Send us mail at: ★☆★
Рекомендации по теме
Комментарии
Автор

Finally Stacks and queues. Thank you very much

teetanrobotics
Автор

Hi Again, Thank you your clear explanation.

yuewu
Автор

sir please provide more stack and queue videos on DS

yashbansal
Автор

Sir implement queue using one stack(mainly explain that function calling)
Thank you

venkatkomminenii
Автор

Is is not necessary to define the push method?

amanbhadouriaom