Skip to content
6
0
:
0
0

Reverse Ticket Chain

Easy

Linked List

In "Reverse Ticket Chain", 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 = [17,18,19,20,21,22]
Output:[22,21,20,19,18,17]

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

Example 2

Input:head = [34,35]
Output:[35,34]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[17,18,19,20,21,22]
Expected Output:
[22,21,20,19,18,17]
Test Case 2
Input:
[34,35]
Expected Output:
[35,34]