Partition a Linked List of Support Tickets by Severity
Last updated: November 29, 2026
Quick Overview
Given the head of a singly linked list of support tickets and a severity threshold, reorder it in place so all tickets with severity below the threshold come first, preserving the original relative order within each group.
IBM
November 29, 20260
0
0 solved
Given the head of a singly linked list of support tickets and a severity threshold, reorder it in place so all tickets with severity below the threshold come first, preserving the original relative order within each group.
IBM Support and IBM Maximo handle large ticket queues, and a stable linked-list partition is a common phone-screen warm-up for IBM software roles. The interviewer checks dummy-node technique, pointer hygiene, and stability.
What the Interviewer Expects
- Use two dummy heads for the two groups
- Preserve relative order within each group
- Terminate the second list to avoid a cycle
- Run in one pass with O(1) extra space
- Trace pointer changes on an example
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you split into three groups (low, medium, critical)?
- How would you do this on a doubly linked list?
- What if you needed the list sorted by severity, stably?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each node has sev (integer) and next. Return the new head. Tickets with sev < threshold come first, then the rest, each group keeping input order. No new nodes should be allocated except dummy h...
High-Level Design
Walk the list once with two tails, one for each group, both starting at dummy nodes. Append each node to the matching tail. At the end connect the low tail to the first real node of the high list and ...