Shortest Result After Candy Crush Removals
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure this Bloomberg problem hinges on is a memo table over strings. It was reported in February 2026, and it looks like Candy Crush but it isn't the greedy stack version. Here you choose the removal order to get the shortest result, with lexicographic tiebreaks. Length is capped at 20, which is the giveaway: the intended solution is search with memoization, not a clever one-pass trick. If you've seen the stack-based Candy Crush, forget it here. If you blank during the live assessment, StealthCoder runs invisibly as a safety net and reads the problem for you.
The problem
In one move, remove any maximal contiguous run of at least three equal characters. The remaining parts collide and may create new removable runs. Return the shortest stable string reachable by choosing removal order optimally. Break equal-length ties lexicographically. Function shortestCandyCrush(text: String) → String Examples Example 1 text = "aaabbbacd" return = "cd" Removing bbb first creates aaaa, which is then removed. Constraints 0 <= text.length <= 20. The text contains lowercase English letters.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Treat the string itself as the state. From any string, find every maximal run of 3 or more equal characters. For each run, remove it, let the neighbors collide, and recurse on the new string. Cache results in a hash map keyed by the string, so repeated states cost nothing. Base case: if no run exists, the string is stable, so return it. Among all recursive results, pick the shortest, and on equal length pick the lexicographically smaller one. The pitfall is removing only part of a run. The problem says maximal run, so don't remove a slice of it. Another trap is greedy order: in aaabbbacd, removing aaa first leaves bbbacd, which collapses to acd, longer than cd. That's why you must try every run. With length at most 20, the number of distinct reachable strings stays small. Watch out for the empty string input and return empty. StealthCoder is there as a hedge if the memoized recursion won't come together under pressure.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Shortest Result After Candy Crush Removals 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. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Shortest Result After Candy Crush Removals FAQ
What's the trick in the Bloomberg shortest Candy Crush problem?+
Try every maximal run as the next removal, recurse on the collapsed string, and memoize by string. Greedy fails because order matters. The small length cap of 20 tells you exhaustive search with caching is the intended approach.
Why doesn't the stack solution work here?+
The classic stack solution applies removals in one fixed pass. This problem asks for the best removal order, so different orders give different final strings. You need to explore choices and compare results, not commit to the first removal.
How do I handle the tiebreak?+
Compare candidates by length first, then lexicographically. While looping over each possible removal, keep a best string. Replace it if the new result is shorter, or equal length and smaller alphabetically. Stable strings with no runs return themselves.
Is the complexity a problem with length 20?+
No. The number of distinct strings reachable by deleting runs is far smaller than the worst case, and memoization avoids recomputing any of them. Each state scans for runs in linear time and builds new strings, which is fine at this size.
How do I prepare for this in 48 hours?+
Write the memoized recursion from scratch once. Test on aaabbbacd, an empty string, a string with no runs, and one where two removals merge into a new run. Make sure you remove maximal runs only, not partial slices.