Skip to content
6
0
:
0
0

Shipment Route Reversal

Easy

Linked List

In "Shipment Route Reversal", 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 = [7,8,9,10]
Output:[10,9,8,7]

For input head = [7,8,9,10], reversing the node direction makes the values appear in reverse order, so the output is [10,9,8,7]. Therefore, return [10,9,8,7].

Example 2

Input:head = [14,15,16,17]
Output:[17,16,15,14]

For input head = [14,15,16,17], reversing the node direction makes the values appear in reverse order, so the output is [17,16,15,14]. Therefore, return [17,16,15,14].

Constraints

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

Test Cases (2)

Test Case 1
Input:
[7,8,9,10]
Expected Output:
[10,9,8,7]
Test Case 2
Input:
[14,15,16,17]
Expected Output:
[17,16,15,14]