Dsa
Linked List
Medium
Parity Boundary Sums
Rearrange a linked list so that all even-valued nodes appear before all odd-valued nodes, while preserving their original relative order. After rearranging, find the 'boundary' where the evens end and odds begin. Insert a new node at this boundary whose value is the sum of the last even node and the first odd node. If the list contains only evens or only odds, do not insert any node.
Example:
Input: 1 2 3 4 5 6
- Rearranged: 2 4 6 1 3 5
- Boundary: 6 (last even), 1 (first odd)
- Sum: 7
Output: 2 4 6 7 1 3 5
Key concepts
linked_listpartitioninginsertion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now