Reported October 2026
ElevenLabscounting

Minimum Magic Stones After Merges

Reported by candidates from ElevenLabs's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live ElevenLabs OA. Under 2s to a working solution.
Founder's read

ElevenLabs reported this one in October 2026, and the input size is the first thing to read: up to 10^5 stones, levels under 10^4. That kills any simulation that picks pairs and merges them one at a time. You need a counting pass that behaves like binary addition with carries. If you've got the OA in a day or two, this is a pattern you can lock in fast. And if you blank on the carry logic mid-assessment, StealthCoder runs invisibly as a safety net and gives you the solution live.

The problem

Each magic stone has a positive integer level. At any time, two stones of the same level may merge into one stone whose level is one greater.
Return the minimum possible number of stones after performing any number of merges.

Function
minimumMagicStones(levels: int[]) → int

Examples
Example 1
levels = [1,2,1]
return = 1
The two level-1 stones merge into level 2, then the two level-2 stones merge into one level-3 stone.
Example 2
levels = [4,4,4]
return = 2
Two stones merge into level 5 and one level-4 stone remains.

Constraints
1 <= levels.length <= 10^5.
1 <= levels[i] < 10^4.
Merged levels may exceed the largest input level.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Count how many stones sit at each level. Then sweep levels from low to high. At level L with count c, floor(c/2) pairs merge up and add to the count at L+1. The leftover c mod 2 is a stone that stays. The answer is the sum of all those leftovers. It's binary carry propagation, where each level is a bit position. The pitfall is stopping at the max input level. Merged levels can exceed it, so keep sweeping until the carried count hits zero, which adds roughly log2(n) extra levels. Use a map or an array sized about 10^4 + 20. A heap or repeated pair-picking is slower and error-prone. Total work is O(n + maxLevel). Check example 2: three 4s give one carry to level 5 and one leftover at 4, plus one leftover at 5, so the answer is 2. If the carry loop slips under pressure, StealthCoder is the hedge for the live OA.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Minimum Magic Stones After Merges 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass ElevenLabs's OA.

ElevenLabs reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Magic Stones After Merges FAQ

What's the trick for Minimum Magic Stones After Merges?+

Treat levels like bit positions. Count stones per level, then carry floor(count/2) to the next level and keep count mod 2 as survivors. The answer is the total of survivors. It's binary addition, not a pairing simulation.

Why can't I just simulate merges one by one?+

With 10^5 stones, a naive approach that searches for pairs and merges repeatedly gets slow and messy. The merge order doesn't change the final count, so a single sweep over counts gives the same result in linear time.

What edge case breaks most solutions?+

Merged levels can go past the largest input level. If you stop your loop at max(levels), you'll miss carries. Size your array with extra room, about 15 to 20 levels, or loop while the carry is nonzero.

Does greedy merging always give the minimum?+

Yes. Merging every available pair at the lowest level first never hurts, since a pair at a level can only reduce stones by merging. Each leftover single stone at a level can't be merged with anything else there.

How do I prepare for this in 48 hours?+

Write the counting-with-carry sweep from scratch twice. Test on [1,2,1], [4,4,4], and a case with 10^5 equal stones to check the carry past the max level. Then do a couple of other counting problems.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with ElevenLabs.

OA at ElevenLabs?
Invisible during screen share
Get it