Odd-Even Linked List
Updated
Problem statement
A singly linked list is serialized by the array values, from head to tail. Reorder the existing nodes so every node at an odd one-based position appears first, followed by every node at an even one-based position.
Preserve the original relative order within both position groups and return the reordered values from head to tail. The first node is at position 1.
Function
oddEvenLinkedList(values: int[]) → int[]Examples
Example 1
values = [1,2,3,4,5]return = [1,3,5,2,4]Positions 1, 3, and 5 stay in order before positions 2 and 4.
Example 2
values = [2,1,3,5,6,4,7]return = [2,3,6,7,1,5,4]Grouping depends on node position, not whether a stored value is odd or even.
Example 3
values = []return = []An empty list remains empty.
Constraints
0 <= values.length <= 100000.-10^9 <= values[i] <= 10^9.
More Bloomberg LP Onsite Interview questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 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
- Rearrange a Linked List from Alternating EndsConcentric AI · ONSITE INTERVIEWConcentric AI 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
- Find the Entry of a Linked List CyclePeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Remove a Cycle from a Singly Linked ListExpedia · ONSITE INTERVIEWExpedia interview questions