Skip to content
6
0
:
0
0

Inbound Link Reversal

Hard

Linked List

In "Inbound Link 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 = [20,21,22,23,24]
Output:[24,23,22,21,20]

For input head = [20,21,22,23,24], reversing the node direction makes the values appear in reverse order, so the output is [24,23,22,21,20]. Therefore, return [24,23,22,21,20].

Example 2

Input:head = [40,41]
Output:[41,40]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[20,21,22,23,24]
Expected Output:
[24,23,22,21,20]
Test Case 2
Input:
[40,41]
Expected Output:
[41,40]