Lowest-Cost Shirt Color Schedule
Reported by candidates from ElevenLabs's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Three numbers per day, three colors, and no repeating a color two days in a row. That's the ElevenLabs OA question reported in October 2026, and it's a paint-house style DP wearing a shirt. The twist is you return the actual color string, not just the cost, so you can't skip the reconstruction step. With up to 10^5 days, anything exponential is dead on arrival. The pattern is dynamic programming with three states per day. If you blank when the OA clock starts, StealthCoder sits invisibly on your screen as a safety net and hands you the solution.
The problem
For each day, costs[i][0], costs[i][1], and costs[i][2] are the costs of wearing a blue, green, or red shirt. Choose exactly one shirt per day, and never choose the same color on consecutive days. Return the unique minimum-cost color sequence using the characters b, g, and r. Function lowestCostShirtColors(costs: int[][]) → String Examples Example 1 costs = [[1,5,9],[4,2,8],[7,6,1]] return = "bgr" Choosing blue, green, then red costs 4 and is the unique optimum. Example 2 costs = [[7,2,5]] return = "g" With one day, choose the least expensive green shirt. Constraints 1 <= costs.length <= 10^5. costs[i].length == 3. 1 <= costs[i][j] <= 10^6. The minimum-cost valid sequence is unique.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: let dp[i][c] be the minimum cost to dress days 0 through i, ending in color c. Then dp[i][c] = costs[i][c] + min(dp[i-1][other two colors]). That's O(n) time with a constant factor of 3. The pitfall is returning only the minimum cost. The problem wants the sequence, so store a parent pointer for each day and color, or keep the full dp table and walk backward from the cheapest final color. Map indexes 0, 1, 2 to b, g, r, and reverse the string you build while backtracking. The constraints guarantee a unique optimum, so you don't need tie-breaking rules. Watch the single-day case, where you just pick the cheapest color. Use a loop, not recursion, since 10^5 days can overflow the stack. If the backtracking logic slips under pressure, StealthCoder can cover you during the live ElevenLabs OA.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Lowest-Cost Shirt Color Schedule 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ElevenLabs's OA.
ElevenLabs reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Lowest-Cost Shirt Color Schedule FAQ
What's the core trick in the Lowest-Cost Shirt Color Schedule problem?+
It's a three-state DP. For each day and color, store the cheapest total cost ending in that color, built from the min of the other two colors the previous day. Then backtrack from the cheapest final state to rebuild the b/g/r string.
How do I reconstruct the color sequence instead of just the cost?+
Keep a parent array the same size as dp, recording which previous color gave the minimum for each day and color. Start at the cheapest color on the last day, follow parents back to day 0, then reverse the characters you collected.
Will a greedy approach work here?+
No. Picking the cheapest allowed shirt each day can force an expensive color the next day. Example 1 shows it: the optimal path accepts blue on day one so green and red are available later. You need DP to compare full paths.
What's the time and space complexity I should aim for?+
O(n) time and O(n) space if you keep parent pointers for reconstruction. The cost values alone only need O(1) rolling space, but backtracking needs the parent info, so linear memory is fine for 10^5 days.
How do I prepare for this in 48 hours?+
Write the paint-house DP from scratch twice, once cost-only and once with reconstruction. Test the single-day case and the two examples. Use iteration, not recursion, and check your index to character mapping before you submit.