9

SDE Sheet - Stack using two queues - GeeksforGeeks | Videos

 8 months ago
source link: https://www.geeksforgeeks.org/videos/sde-sheet-stack-using-two-queues/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Stack using two queues

January 10, 2024 |100 Views
SDE Sheet - Stack using two queues
SDE Sheet, GFG SDE Sheet, stack, queue
 Save  Share   Like
Description
Discussion

This video is part of Stack and Queues section under GFG SDE Sheet.

In this problem, we have to Implement a Stack using two queues q1 and q2.

Example :

Input:
push(2)
push(3)
pop()
push(4)
pop()
Output: 3 4

Explanation:
push(2) the stack will be {2}
push(3) the stack will be {2 3}
pop()   poped element will be 3 the 
       stack will be {2}
push(4) the stack will be {2 4}
pop()   poped element will be 4 

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/implement-stack-using-queue/
Problem: https://www.geeksforgeeks.org/problems/stack-using-two-queues/1
SDE Sheet Link:https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK