Skip to content
6
0
:
0
0

Reverse Job Pipeline

Hard

Linked List

In "Reverse Job Pipeline", 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 = [15,16,17,18]
Output:[18,17,16,15]

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

Example 2

Input:head = [30,31,32]
Output:[32,31,30]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[15,16,17,18]
Expected Output:
[18,17,16,15]
Test Case 2
Input:
[30,31,32]
Expected Output:
[32,31,30]