Skip to content
6
0
:
0
0

Node Rewind Operation

Medium

Linked List

In "Node Rewind Operation", 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 = [21,22,23,24,25,26]
Output:[26,25,24,23,22,21]

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

Example 2

Input:head = [42,43,44]
Output:[44,43,42]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[21,22,23,24,25,26]
Expected Output:
[26,25,24,23,22,21]
Test Case 2
Input:
[42,43,44]
Expected Output:
[44,43,42]