This video contains Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, …
from geeksforgeeks platform.
website link:
https://www.geeksforgeeks.org/must-do...
Topics covered in this video series are:
1.Arrays
• 1.1 ARRAYS | Must Do Coding Questions
2.String
• 1.2 STRING | Must Do Coding Questions
3.Linked List
• 1.3 LINKED LIST | Must Do Coding Questions
4.Stack and Queue
5.Tree and BST
6.Heap
7.Recursion
8.Hashing
9.Graph
10.Greedy
11.Dynamic Programming
12.Divide and Conquer
13.Backtracking
14.Bit Magic
Stack and Queue:
3: Queue using two Stacks:
Implement a Queue using 2 stacks s1 and s2 .
A Query Q is of 2 Types
(i) 1 x (a query of this type means pushing 'x' into the queue)
(ii) 2 (a query of this type means to pop element from queue and print the poped element)
Example 1:
Input:
5
1 2 1 3 2 1 4 2
Output:
2 3
Explanation:
In the first testcase
1 2 the queue will be {2}
1 3 the queue will be {2 3}
2 poped element will be 2 the queue
will be {3}
1 4 the queue will be {3 4}
2 poped element will be 3.
Example 2:
Input:
4
1 2 2 2 1 4
Output:
2 -1
Explanation:
In the second testcase
1 2 the queue will be {2}
2 poped element will be 2 and
then the queue will be empty
2 the queue is empty and hence -1
1 4 the queue will be {4}.
Code Link:
https://github.com/krishna-gavas/Comp...
Intro Music :
• Video p
Nesta página do site você pode assistir ao vídeo on-line Stack & Queue 3: Queue using two stacks | Must Do Coding Questions | GeeksForGeeks duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Krishna Teaches 30 Julho 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 762 vezes e gostou 19 espectadores. Boa visualização!