Wizard Scroll Allocation Strategy
Reported by candidates from Jane Street's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Jane Street reported this one in October 2026, and the title sounds like a fantasy game while the task is a scheduling problem in disguise. Ten scrolls arrive every morning, leftovers carry over, and each day one monster shows up with a cost. You pick which to fight. The real question is which structure keeps your choices cheap to undo, and the answer is a max-heap. If you blank on the tie-break rules during the live OA, StealthCoder runs invisibly as a safety net while you work.
The problem
A wizard receives ten scrolls at the start of every day, and unused scrolls persist. On day i, one monster with cost costs[i] appears. The wizard may defeat that monster only on that day by spending its cost. Return the zero-based days on which the wizard should defeat monsters. Maximize the number defeated, then minimize total scrolls spent, then choose the lexicographically smallest day list. Function chooseMonsterDays(costs: int[]) → int[] Examples Example 1 costs = [5,25,5] return = [0,2] Defeating days 0 and 2 costs ten scrolls total and is feasible; no schedule defeats all three monsters. Example 2 costs = [10,20,30] return = [0] Only one monster can be defeated. Day 0 has the smallest total spend and therefore wins the tie. Constraints 1 <= costs.length <= 20. 1 <= costs[i] <= 10^4. A selected schedule is feasible when cumulative spending through every day is at most 10 * (day + 1).
Reported by candidates. Source: FastPrep
Pattern and pitfall
The feasibility rule is a prefix constraint: cumulative spend through day d can't exceed 10 * (d + 1). Walk the days in order, take every monster, and push its cost onto a max-heap. When the running total goes over budget, pop the most expensive monster you've taken and drop it. That exchange argument maximizes the count while keeping total spend minimal. The trap is the third rule. Lexicographically smallest day list means you must break ties in cost by dropping the later day, so store (cost, day) and pop the larger day on equal cost. With length at most 20, a bitmask brute force also works and is easier to get right. Check Example 1 by hand: the total is 35 against a budget of 30, so the 25 gets dropped and you return [0,2]. If the heap tie-break fails under pressure, StealthCoder is your hedge in the live 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 Wizard Scroll Allocation Strategy 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 Jane Street's OA.
Jane Street 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.
Wizard Scroll Allocation Strategy FAQ
What's the trick in the Wizard Scroll Allocation problem?+
Treat it as a prefix-budget scheduling problem. Take each monster as it arrives, track cumulative spend, and when it exceeds 10 * (day + 1), evict the most expensive chosen monster using a max-heap. That keeps the count maximal and the spend minimal.
Can I just brute force it?+
Yes. With costs.length at most 20 there are about a million subsets. Enumerate bitmasks, check the prefix constraint, then compare by count, total spend, and lexicographic order of days. It's slower but harder to get wrong on the tie-breaks.
How do the tie-breaks work?+
Order by most monsters, then lowest total spend, then lexicographically smallest day list. In the heap approach, when two monsters have equal cost, evict the one on the later day so the earlier days survive in the result.
How hard is this really?+
Medium. The idea of evicting the priciest item on overflow is a known greedy pattern. The difficulty is proving the tie-breaks and not mishandling the carry-over budget. Small constraints let you fall back to brute force.
How do I prepare for this in 48 hours?+
Practice greedy-with-heap problems where you undo the worst choice when a constraint breaks. Then write the bitmask version as a checker. Test both against the two given examples and a case with equal costs to verify the lexicographic rule.