Skip to content
6
0
:
0
0

Message Chain Flip: Service Chain Edition

Medium

Linked List

In "Message Chain Flip: Service Chain 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 = [26,27,28]
Output:[28,27,26]

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

Example 2

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

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

Constraints

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

Test Cases (2)

Test Case 1
Input:
[26,27,28]
Expected Output:
[28,27,26]
Test Case 2
Input:
[52,53]
Expected Output:
[53,52]