6
0
:0
0
Node Direction Swap
Node Direction Swap
Medium
Linked List
In "Node Direction Swap", 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 = [13,14,15,16,17,18]Output:
[18,17,16,15,14,13]For input head = [13,14,15,16,17,18], reversing the node direction makes the values appear in reverse order, so the output is [18,17,16,15,14,13]. Therefore, return [18,17,16,15,14,13].
Example 2
Input:
head = [26,27,28,29]Output:
[29,28,27,26]For input head = [26,27,28,29], reversing the node direction makes the values appear in reverse order, so the output is [29,28,27,26]. Therefore, return [29,28,27,26].
Constraints
0 <= head.length <= 5000-5000 <= head[i] <= 5000
solution.js
Loading...
Test Cases (2)
Test Case 1
Input:
[13,14,15,16,17,18]Expected Output:
[18,17,16,15,14,13]Test Case 2
Input:
[26,27,28,29]Expected Output:
[29,28,27,26]