Skip to content
6
0
:
0
0

Reverse Playlist Nodes

Hard

Linked List

In "Reverse Playlist Nodes", 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 = [5,6,7,8,9,10]
Output:[10,9,8,7,6,5]

For input head = [5,6,7,8,9,10], reversing the node direction makes the values appear in reverse order, so the output is [10,9,8,7,6,5]. Therefore, return [10,9,8,7,6,5].

Example 2

Input:head = [10,11]
Output:[11,10]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[5,6,7,8,9,10]
Expected Output:
[10,9,8,7,6,5]
Test Case 2
Input:
[10,11]
Expected Output:
[11,10]