Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Solution: Reverse a Queue
On this page

Problem Statement

Given a queue containing integer elements, return the updated queue after reversing its elements.

Examples

Example 1

  • Input: queue = [1, 2, 3, 4, 5]
  • Expected Output: [5, 4, 3, 2, 1]
  • Explanation: The input queue elements are reversed.

Example 2

  • Input: queue = [10, 20, 30, 40, 50]
  • Expected Output: [50, 40, 30, 20, 10]
  • Explanation: The input queue elements are reversed.

Example 3

  • Input: queue = [5, 7, 12, 2, 4, 5]
  • Expected Output: [5, 4, 2, 12, 7, 5]

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page