Skip to content
6
0
:
0
0

Emergency Route Reverse

Easy

Linked List

In "Emergency Route Reverse", 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 = [14,15,16]
Output:[16,15,14]

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

Example 2

Input:head = [28,29]
Output:[29,28]

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[14,15,16]
Expected Output:
[16,15,14]
Test Case 2
Input:
[28,29]
Expected Output:
[29,28]