Skip to content
6
0
:
0
0

Reverse Audit Trail

Easy

Linked List

In "Reverse Audit Trail", 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 = [19,20,21,22]
Output:[22,21,20,19]

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

Example 2

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

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[19,20,21,22]
Expected Output:
[22,21,20,19]
Test Case 2
Input:
[38,39,40,41]
Expected Output:
[41,40,39,38]