HARDasked at 1 company

Minimum Runes to Add to Cast Spell

A hard-tier problem at 43% community acceptance, tagged with Array, Depth-First Search, Breadth-First Search. Reported in interviews at DE Shaw and 0 others.

Founder's read

Minimum Runes to Add to Cast Spell is a hard graph problem that only 42.5% of candidates solve on their first attempt. DE Shaw has asked it directly. The problem wraps a dependency or prerequisite pattern inside fantasy language, which trips up candidates who miss the underlying structure. You're either solving a reachability or connectivity constraint with an implicit ordering. The obvious greedy move fails because you can't see the whole graph at once. If you hit this during your live OA and freeze on the logic, StealthCoder reads the problem in seconds and surfaces a working solution while the proctor sees nothing.

Companies asking
1
Difficulty
HARD
Acceptance
43%

Companies that ask "Minimum Runes to Add to Cast Spell"

If this hits your live OA

Minimum Runes to Add to Cast Spell is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The trick is recognizing that 'runes' correspond to graph nodes or state transitions, and 'casting a spell' encodes a constraint: you need to reach a target state, satisfy all dependencies, or connect components. This is not a simple shortest-path problem. You'll likely need to build an explicit graph, then either run DFS to find unreachable nodes, use Union Find to check connectivity, or apply topological sort to order your additions. The trap is thinking greedy: picking one rune at a time and assuming it works. In reality, you need to simulate the effect of each candidate rune on the entire graph, which is expensive but necessary. Candidates often skip the simulation step and submit a wrong count. When StealthCoder is running invisibly during your assessment, it builds the graph correctly and iterates through candidate runes, testing connectivity or reachability after each hypothetical addition until the spell completes.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Minimum Runes to Add to Cast Spell recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Runes to Add to Cast Spell interview FAQ

How hard is this compared to other DE Shaw graph problems?+

The 42.5% acceptance rate puts it solidly in hard territory, and only DE Shaw in the input data asked it, which suggests it's a specialized filter. You're not seeing this at every company. The problem requires multiple graph techniques in sequence, not just one, which elevates difficulty beyond standard shortest-path or BFS.

Is this really a Union Find problem or a DFS problem?+

Both can work, depending on the exact constraint. If you're checking whether all nodes are connected, Union Find is cleaner and faster. If you're tracking reachability from a source to a target with conditional edges, DFS is more natural. The input lists both Array, DFS, BFS, and Union Find as topics, so any of these approaches is valid if you pick the right one for the specific constraint.

What's the most common mistake on this problem?+

Greedy selection without validation. Candidates pick a single rune they think will help, add it, and move on. The real solution requires you to test each candidate rune by actually simulating the graph change and checking if the goal is met. Missing this simulation step is why so many submissions fail.

Does topological sort actually help here?+

Yes, if the spell-casting has an order dependency: you can only cast spell B after spell A. Topological sort tells you the legal orderings and which runes break the order. If the problem mentions 'prerequisites' or 'order', topological sort is almost certainly part of the intended solution.

How should I structure my solution if I have 15 minutes and haven't seen the pattern?+

Build the graph explicitly first (Array input, adjacency list output). Then pick a traversal: DFS or BFS to check reachability from your starting rune to the target. If connectivity is the question, use Union Find. Test your approach on a small example before coding the full simulation loop. StealthCoder runs invisibly during live assessment and handles the iteration, so you get the working solution even if you blank on the trick.

Want the actual problem statement? View "Minimum Runes to Add to Cast Spell" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.