Skip to content
6
0
:
0
0

Backorder Chain Flip

Medium

Linked List

In "Backorder Chain Flip", 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 = [16,17,18,19,20]
Output:[20,19,18,17,16]

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

Example 2

Input:head = [32,33,34,35]
Output:[35,34,33,32]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[16,17,18,19,20]
Expected Output:
[20,19,18,17,16]
Test Case 2
Input:
[32,33,34,35]
Expected Output:
[35,34,33,32]