As reported: Bloomberg Senior Software Engineer (New York, 2025), phone screen with two interviewers, one coding question each. Question: a candy-crush variant on a string — remove runs of three or more equal letters, repeatedly.
You are given a string s of uppercase letters. A run is a maximal block of equal adjacent letters. Crushing works in steps:
- Remove every run of length 3 or more that is in the string at this moment, all at once.
- The remaining pieces join together; this may create new runs of 3 or more.
- Repeat until no run of length 3 or more is left.
Return the final string (possibly empty).
Example 1
s = "ABCCCBB"
Output: "A"
CCC is crushed, leaving ABBB; then BBB is crushed.
Example 2
s = "ABBBBBC"
Output: "AC"
All five Bs form one run.
Example 3
s = "ABBBAAA"
Output: "A"
BBB and AAA are crushed in the same step, leaving A.
Constraints: 1 ≤ s.length ≤ 1000; s contains uppercase English letters.
Code runner format: one JSON value per line: s. Implement crush(s); the harness prints the resulting string.