FastPrepRearrange a Linked List from Alternating Ends
Problems/Rearrange a Linked List from Alternating Ends

Rearrange a Linked List from Alternating Ends

Concentric AI logoConcentric AI● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Concentric AI new grad onsite interview. The report gives the main task and what the interview was like. We rebuilt the function signature, the tie rule, the examples, and the limits as close to the report as we could. Our version is about 90% the same as the reported question.

Rearrange a singly linked list L0 → L1 → … → Ln into L0 → Ln → L1 → Ln-1 → ….

Reuse the existing nodes and return the head. Do not change node values.

Function

rearrangeList(head: ListNode) → ListNode

Examples

Example 1

head = [1,2,3,4]return = [1,4,2,3]
head
1234
→
return
1423
Moved or new

The alternating order is 1,4,2,3.

Example 2

head = [1,2,3,4,5]return = [1,5,2,4,3]
head
12345
→
return
15243
Moved or new

The middle node remains last.

Example 3

head = []return = []
head
empty
return
empty

An empty list stays empty.

Constraints

  • The list contains at most 100000 nodes.
  • Node values fit in a signed 32-bit integer.

More Concentric AI interview questions

  • Kth Greater Element Index to the RightOA · Seen Sep 2026
  • Find the Intersection Node of Two Linked ListsOA · Seen Sep 2026
  • Count Students Outside Their Sorted PositionsOA · Seen Aug 2026
  • Maximum Profit Under a Bitwise OR LimitOA · Seen Aug 2026
  • Minimum Weighted Manhattan Travel CostOA · Seen Aug 2026

Similar questions at other companies

  • Remove Nth Node From End of ListDruva · ONSITE INTERVIEW
  • Find the Entry of a Linked List CycleQualys · ONSITE INTERVIEWQualys interview questions
  • Detect a Linked-List CyclePaytm · ONSITE INTERVIEWPaytm interview questions
  • Detect a Linked-List CycleCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Palindrome Linked List with RestorationMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Linked List Cycle Entry NodeGoogle · ONSITE INTERVIEWGoogle interview questions
  • Detect and Break a Linked-List CycleAmazon · ONSITE INTERVIEW
  • Odd-Even Linked ListBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Find the Entry of a Linked List CyclePeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Remove a Cycle from a Singly Linked ListExpedia · ONSITE INTERVIEWExpedia interview questions
All Concentric AI interview questionsSee Concentric AI hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode rearrangeList(ListNode head) {
        // write your code here
    }
}
Checking account…