Skip to content
6
0
:
0
0

Shipment Route Reversal: Queue Restore Edition

Easy

Linked List

In "Shipment Route Reversal: Queue Restore Edition", a singly linked sequence is represented as an array in input order.

Return the sequence in reversed order as if the linked list pointers were fully reversed.

Example 1

Input:head = [27,28,29,30]
Output:[30,29,28,27]

For input head = [27,28,29,30], reversing the node direction makes the values appear in reverse order, so the output is [30,29,28,27]. Therefore, return [30,29,28,27].

Example 2

Input:head = [54,55,56]
Output:[56,55,54]

For input head = [54,55,56], reversing the node direction makes the values appear in reverse order, so the output is [56,55,54]. Therefore, return [56,55,54].

Constraints

  • 0 <= head.length <= 5000
  • -5000 <= head[i] <= 5000
solution.js
Loading...

Test Cases (2)

Test Case 1
Input:
[27,28,29,30]
Expected Output:
[30,29,28,27]
Test Case 2
Input:
[54,55,56]
Expected Output:
[56,55,54]