6
0
:0
0
Undo Recent Events: History Undo Edition
Undo Recent Events: History Undo Edition
Easy
Linked List
In "Undo Recent Events: History Undo Edition", 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 = [22,23,24]Output:
[24,23,22]For input head = [22,23,24], reversing the node direction makes the values appear in reverse order, so the output is [24,23,22]. Therefore, return [24,23,22].
Example 2
Input:
head = [44,45,46,47]Output:
[47,46,45,44]For input head = [44,45,46,47], reversing the node direction makes the values appear in reverse order, so the output is [47,46,45,44]. Therefore, return [47,46,45,44].
Constraints
0 <= head.length <= 5000-5000 <= head[i] <= 5000
solution.js
Loading...
Test Cases (2)
Test Case 1
Input:
[22,23,24]Expected Output:
[24,23,22]Test Case 2
Input:
[44,45,46,47]Expected Output:
[47,46,45,44]