Insert into an Unrolled Linked List
Reported by candidates from Indeed's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Indeed reported this one in September 2026, and the detail that trips people is the boundary rule: an index sitting exactly between two nodes belongs to the following node. It's an unrolled linked list insert, modeled as an array of rows, and it's mostly careful case handling rather than a clever algorithm. If your OA invite is two days out, this is the kind of problem where one off-by-one costs you every hidden test. StealthCoder is the safety net if you blank mid-assessment, but the logic below is short enough to carry in your head.
The problem
An unrolled linked list is represented by nodes, where every row stores one node's active integer values and has length at most nodeCapacity. Concatenating the rows gives the logical list. Insert value before logical position index, where index may equal the total size. If the selected node has space, insert in that node. If insertion occurs strictly inside a full node, keep the prefix and new value in that node and move the suffix into one newly inserted following node. An index at a node boundary belongs to the following node when one exists. Appending after a full final node creates a one-value node. Return all node rows after insertion. Function insertUnrolled(nodes: int[][], nodeCapacity: int, index: int, value: int) → int[][] Examples Example 1 nodes = [[9,6,7,4,10]] nodeCapacity = 5 index = 2 value = 8 return = [[9,6,8],[7,4,10]] The full node splits at the insertion point: its prefix and 8 stay first, and the old suffix moves to the new node. Example 2 nodes = [[1,2],[3]] nodeCapacity = 3 index = 2 value = 9 return = [[1,2],[9,3]] The boundary index belongs to the next node, which has capacity. Constraints 1 <= nodes.length <= 100000. 1 <= nodes[i].length <= nodeCapacity <= 1000. 0 <= index <= total number of stored values. All values fit signed 32-bit integers.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is walking the rows while subtracting each row's length from index, until index is less than the current row's length or you run out of rows. Strictly less means a boundary index naturally rolls into the next node, which matches the rule. If you run out of rows, you're appending: add to the last node if it has space, else create a one-value node. If the target node has space, splice the value in. If it's full and the position is strictly inside, keep prefix plus the new value, then push the suffix into a new node right after. The pitfall is index 0 of a full node. That's a boundary, not a split, and it still lands in the first node, so check that case carefully. Nodes can hold 100000 rows, so don't copy the whole structure. StealthCoder is your hedge in the live OA if the edge cases blur together under pressure.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Insert into an Unrolled Linked List cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Indeed's OA.
Indeed reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Insert into an Unrolled Linked List FAQ
What's the trick to the Indeed unrolled linked list insert?+
Walk the rows, subtracting each row's length from index until index is strictly less than the current row's length. That handles the boundary rule for free. Then branch on three cases: room in the node, full node with a mid-node split, or append past the end.
How hard is this problem really?+
Easy algorithmically, annoying in the details. There's no fancy data structure, just a linear scan and array splicing. Most failures come from boundary and append cases, not from the core idea. Expect hidden tests to hammer those.
When does a split happen versus a plain insert?+
A split only happens when the target node is full and the insertion point is strictly inside it. If the node has space, you insert in place. If the index is at a boundary, it goes to the following node, which may have space and avoid a split entirely.
What happens when I append after a full final node?+
When index equals total size and the last node is at nodeCapacity, you create a new node holding just the value. If the last node has room, you add the value to it instead. Check capacity before deciding.
How do I prepare for this in 48 hours?+
Hand-trace both examples, then write your own cases: index 0, index at a boundary into a full node, index equal to total size, and a split at the last position. Code the scan first, then the three branches. Test those edges before anything else.