Grokking the Engineering Manager Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Reverse a Queue (easy)
On this page

Problem Statement

Examples

Try it yourself

Problem Statement

Given the head of a singly linked list, return the head of the reversed list.

Examples

Example 1:

  • Input: [3, 5, 2]
  • Expected Output: [2, 5, 3]
  • Justification: Reversing the list [3, 5, 2] gives us [2, 5, 3].

Example 2:

  • Input: [7]
  • Expected Output: [7]
  • Justification: Since there is only one element in the list, the reversed list remains the same.

Example 3:

  • Input: [-1, 0, 1]
  • Expected Output: [1, 0, -1]
  • Justification: The list is reversed, so the elements are in the order [1, 0, -1].

Try it yourself

Try solving this question here:

Python3
Python3

. . . .

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

Problem Statement

Examples

Try it yourself