Skip to content
6
0
:
0
0

Reverse Task Queue

Medium

Linked List

In "Reverse Task Queue", 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 = [3,4,5,6]
Output:[6,5,4,3]

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

Example 2

Input:head = [6,7,8]
Output:[8,7,6]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[3,4,5,6]
Expected Output:
[6,5,4,3]
Test Case 2
Input:
[6,7,8]
Expected Output:
[8,7,6]