6
0
:0
0
Access History Reverse
Access History Reverse
Medium
Linked List
In "Access History Reverse", 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 = [8,9,10,11,12]Output:
[12,11,10,9,8]For input head = [8,9,10,11,12], reversing the node direction makes the values appear in reverse order, so the output is [12,11,10,9,8]. Therefore, return [12,11,10,9,8].
Example 2
Input:
head = [16,17]Output:
[17,16]For input head = [16,17], reversing the node direction makes the values appear in reverse order, so the output is [17,16]. Therefore, return [17,16].
Constraints
0 <= head.length <= 5000-5000 <= head[i] <= 5000
solution.js
Loading...
Test Cases (2)
Test Case 1
Input:
[8,9,10,11,12]Expected Output:
[12,11,10,9,8]Test Case 2
Input:
[16,17]Expected Output:
[17,16]