• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
September 20, 2023 |210 Views
SDE Sheet - Implement Queue using Linked List
  Share   Like
Description
Discussion

This video is a part of Linked List section under GFG SDE Sheet.

In this video, we have to Implement a Queue using Linked List. 
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 an element from the queue and print the poped element)

Example :

Input:
Q = 5
Queries = 1 2 1 3 2 1 4 2

Output: 2 3

Explanation: n 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.

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/queue-Linked-list-implementation/
Problem: https://practice.geeksforgeeks.org/problems/implement-queue-using-linked-list/1
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More