0% completed
Reverse a Queue (easy)
Problem Statement
Given a queue containing integer elements, return the updated queue after reversing its elements.
Examples
Example 1:
- Input:
[3, 5, 2] - Expected Output:
[2, 5, 3] - Justification: Reversing the queue
[3, 5, 2]gives us[2, 5, 3].
Example 2:
- Input:
[7] - Expected Output:
[7] - Justification: Since there is only one element in the queue, the reversed queue remains the same.
Example 3:
- Input:
[-1, 0, 1] - Expected Output:
[1, 0, -1]
.....
.....
.....
growth.mindset.247365
· 2 months ago
Why is the question asking to reverse a linked list while the solution is for reversing a queue? When do we assume the queue is a double ended queue?
erickchhuang
· a year ago
Moshe Peretz
· 2 years ago
i wrote "while(queue.isEmpty())" but its show me runtime erorr that isEmpty is not function
Daven L
· 2 years ago
Is it possible to get more detailed feedback on these queue questions?
I am getting Unknown Error - Check your Input
I don't know what type queue is, so I tried printing it to see if it is of type Node or if it is a list in order to begin working through this problem.
odhran.19
· 3 years ago
I want some clarity on what implementation of a Queue we should expect to see in the problem set. In the first problem the queue is implemented as a list, in Python.
It was not clear that the front of the 'queue' should be the 0 index of the list?
Why show a Queue that uses Node and .next, .enqueue, .dequeue functions if these are not used?
In a real interview leetcode/hackerrank/coderpad what approach should we use?
Leopoldo Hernandez
· 3 years ago
However... this doesn't have them and uses arrays instead. What is the point of teaching stacks and queues?
SK
· 3 years ago
Why are we using peek() instead of remove() and pop() ?
Reading Progress
0%