Reorder Existing Nodes from Alternating List Ends

Quick Overview

Reorder existing list nodes in first-last alternating order by splitting, reversing and weaving next links.

Reorder Existing Nodes from Alternating List Ends

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem Reorder the existing nodes of a singly linked list by alternating from its beginning and end. If the original node identities are `L0,L1,...,Lk`, the result is `L0,Lk,L1,L(k-1),...`. Do not change any node's stored value. ```cpp void reorderList(ListNode* head); ``` Keep the original `ListNode` objects and mutate their next links; the function returns nothing. Display brackets show node values along the chain. ### Examples ```text Input: head = [2,5,8,11,14] Chain after call: [2,14,5,11,8] ``` ```text Input: head = [3,6,9,12] Chain after call: [3,12,6,9] ``` ### Constraints - There are between 1 and 50000 nodes. - Values are between 1 and 1000, inclusive.

Overview: Reorder existing list nodes in first-last alternating order by splitting, reversing and weaving next links.

Google logo
Google
Oct 7, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

Reorder the existing nodes of a singly linked list by alternating from its beginning and end. If the original node identities are L0,L1,...,Lk, the result is L0,Lk,L1,L(k-1),.... Do not change any node's stored value.

void reorderList(ListNode* head);

Keep the original ListNode objects and mutate their next links; the function returns nothing. Display brackets show node values along the chain.

Examples

Input: head = [2,5,8,11,14]
Chain after call: [2,14,5,11,8]
Input: head = [3,6,9,12]
Chain after call: [3,12,6,9]

Constraints

  • There are between 1 and 50000 nodes.
  • Values are between 1 and 1000, inclusive.