geeksforgeeks
  • Courses
  • Tutorials
  • Practice
  • Jobs
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
Videos
July 07, 2022 |7.0K Views

Interleave the first half of the queue with second half

stack, Queue, queue, Stack
 Save  Share  1 Like
Description
Discussion

Given a queue of integers of even length, rearrange the elements by interleaving the first half of the queue with the second half of the queue.  

Examples:

Input :  1 2 3 4
Output : 1 3 2 4

Input : 11 12 13 14 15 16 17 18 19 20
Output : 11 16 12 17 13 18 14 19 15 20


Interleave the first half of the queue with second half : https://www.geeksforgeeks.org/interleave-first-half-queue-second-half/

Recommendations
Video Thumbnail
08:06
Video Thumbnail
55.0K Views | 10/01/2025...
Reverse a stack using recursion
Video Thumbnail
02:38
Video Thumbnail
30.5K Views | 10/01/2025...
Design and Implement Special Stack Data Structure
Video Thumbnail
06:43
Video Thumbnail
25.0K Views | 10/01/2025...
Iterative Preorder Traversal
Video Thumbnail
27:18
Video Thumbnail
76.0K Views | 09/01/2025...
The Stock Span Problem
Video Thumbnail
04:59
Video Thumbnail
13.8K Views | 08/01/2025...
Check if a given array can represent Preorder Traversal of Binary Search Tree
Video Thumbnail
07:37
Video Thumbnail
43.1K Views | 04/01/2025...
Queue | Set 2 (Linked List Implementation)
Video Thumbnail
10:24
Video Thumbnail
74.8K Views | 04/01/2025...
Stack | Set 4 (Evaluation of Postfix Expression)
Video Thumbnail
06:30
Video Thumbnail
16.0K Views | 23/08/2024...
WHAT IS STACK? | Stack Data Structures | DSA Course
Video Thumbnail
07:03
Video Thumbnail
6.8K Views | 23/08/2024...
Reversing a queue using recursion
Video Thumbnail
11:51
Video Thumbnail
32.4K Views | 21/08/2024...
Queue | Set 1 (Introduction and Array Implementation)
GeeksforGeeks
location
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
location
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play StoreGFG App on App Store
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • Careers
  • Contact Us
  • Corporate Solution
  • Campus Training Program
  • Explore
  • POTD
  • Practice Problems
  • Connect
  • Blogs
  • Upskill Courses
  • Tutorials
  • Programming Languages
  • DSA
  • Web Technology
  • AI, ML & Data Science
  • DevOps
  • CS Core Subjects
  • GATE
  • School Subjects
  • Software and Tools
  • Courses
  • ML and Data Science
  • DSA and Placements
  • Web Development
  • Data Science
  • Programming Languages
  • DevOps & Cloud
  • GATE
  • MongoDB Certifications
  • Offline Centers
  • Noida
  • Bengaluru
  • Hyderabad
  • Kolkata
  • Preparation Corner
  • Interview Corner
  • Aptitude
  • Puzzles
  • GfG 160
  • System Design
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved