Skip to content
6
0
:
0
0

Reverse Playlist Nodes: Signal Replay Edition

Hard

Linked List

In "Reverse Playlist Nodes: Signal Replay 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 = [25,26,27,28,29,30]
Output:[30,29,28,27,26,25]

For input head = [25,26,27,28,29,30], reversing the node direction makes the values appear in reverse order, so the output is [30,29,28,27,26,25]. Therefore, return [30,29,28,27,26,25].

Example 2

Input:head = [50,51,52,53]
Output:[53,52,51,50]

For input head = [50,51,52,53], reversing the node direction makes the values appear in reverse order, so the output is [53,52,51,50]. Therefore, return [53,52,51,50].

Constraints

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

Test Cases (2)

Test Case 1
Input:
[25,26,27,28,29,30]
Expected Output:
[30,29,28,27,26,25]
Test Case 2
Input:
[50,51,52,53]
Expected Output:
[53,52,51,50]