Skip to content
6
0
:
0
0

Call Log Rewind

Easy

Linked List

In "Call Log Rewind", 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 = [12,13,14,15,16]
Output:[16,15,14,13,12]

For input head = [12,13,14,15,16], reversing the node direction makes the values appear in reverse order, so the output is [16,15,14,13,12]. Therefore, return [16,15,14,13,12].

Example 2

Input:head = [24,25,26]
Output:[26,25,24]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[12,13,14,15,16]
Expected Output:
[16,15,14,13,12]
Test Case 2
Input:
[24,25,26]
Expected Output:
[26,25,24]