One-Dimensional Candy Crush
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Bloomberg reportedly put "One-Dimensional Candy Crush" in front of candidates in February 2026, and the input size is the whole story. With s up to 10^5 characters, rescanning the string after every removal turns into O(n^2) and dies. If you've got an OA coming, this is a stack problem with run counts, and once you see it the code is short. The cascading removals are the bait. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the pattern below is simple enough to carry in your head.
The problem
Given a string s and an integer threshold k, repeatedly remove any maximal contiguous run of at least k equal characters. Process runs from left to right. After a removal, the characters on its two sides become adjacent and may form a new qualifying run. Continue until no qualifying run remains, then return the remaining string. Function crushCandy(s: String, k: int) → String Examples Example 1 s = "aaabbbc" k = 3 return = "c" Remove aaa, then remove the newly exposed run bbb. Example 2 s = "aabbbacd" k = 3 return = "cd" Removing bbb joins two and one a into aaa, which is removed next. Example 3 s = "aabbccddeeedcba" k = 3 return = "" Each removal exposes the next three-character run until the string is empty. Constraints 0 <= s.length <= 10^5. 2 <= k <= 10^5. s contains lowercase English letters.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: keep a stack of pairs (character, count). Walk the string once. If the top of the stack matches the current character, increment its count. Otherwise push a new pair with count 1. When a count reaches k, pop it. The next character then compares against whatever is now on top, so merges like aabbbacd collapsing into aaa happen automatically with no rescanning. That's O(n) time and O(n) space. The common pitfall is removing at exactly k and missing that a run can only be at least k because you pop the moment it hits k, so it never grows past it. Another trap is the brute force loop of scan, delete, rescan. That's what the constraints are built to punish. Rebuild the output by expanding each pair (char times count) at the end. Handle the empty string and k larger than the length. If you freeze during the live OA, StealthCoder can hand you this stack solution in real time.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill One-Dimensional Candy Crush 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
This OA pattern shows up on LeetCode as remove all adjacent duplicates in string ii. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg 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.
One-Dimensional Candy Crush FAQ
What's the trick in Bloomberg's One-Dimensional Candy Crush?+
Use a stack of (character, count) pairs. Increment the top's count when the character matches, push a new pair otherwise, and pop when the count hits k. Cascading merges resolve themselves because the next character compares against the new top. One pass, O(n).
Why does brute force fail here?+
The string can be 10^5 characters long. Scanning for a run, deleting it, and rescanning from the start can cost O(n) per removal across many removals, which approaches O(n^2). That's too slow at this size. The stack avoids all rescanning.
How hard is this problem really?+
Medium. The idea is short once you've seen a stack with counts, but the cascade in Example 2 trips people who try string replace loops. If you can explain why popping at count k handles merging, you're fine.
What edge cases should I test before submitting?+
Test the empty string, a string where everything collapses to empty like Example 3, a string with no runs of length k, and k bigger than the string length. Also check a merge where two separate groups of the same letter join after a middle removal.
How do I prepare for this in 48 hours?+
Write the stack-with-counts solution from scratch twice, then trace Example 2 by hand. Also do a similar remove-adjacent-duplicates problem. The pattern transfers, and you only need to be fluent with push, increment, pop, and rebuilding the string.