FastPrepOne-Dimensional Candy Crush
Problems/One-Dimensional Candy Crush

One-Dimensional Candy Crush

Bloomberg LP logoBloomberg LP● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported across many first-hand Bloomberg new-grad phone and onsite interview experiences. This is the maximal-run variant: an entire run is removed when its length reaches the threshold.

Given a string s and a threshold k, return the string left after repeatedly removing qualifying runs from left to right.

A run is a maximal group of equal characters next to each other: it includes every matching character on either side. Remove the entire run when its length is at least k.

After a removal, the characters on its two sides become neighbors and may form another qualifying run. Continue until no qualifying run remains.

Function

crushCandy(s: String, k: int) → String

Examples

Example 1

s = "aaabbbc"k = 3return = "c"

Remove aaa, then remove the newly exposed run bbb.

Example 2

s = "aabbbacd"k = 3return = "cd"

Removing bbb joins the a characters on either side into aaa. Removing that run leaves cd.

Example 3

s = "aabbccddeeedcba"k = 3return = ""

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.

More Bloomberg LP Phone Screen questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Adjacent Pair and Run RemovalWhatNot · PHONE SCREENWhatNot interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Multiline Text Editor with Cursor MovementDatologyAI · PHONE SCREEN
  • Run a Stack Language InterpreterJane Street · PHONE SCREENJane Street interview questions
  • Trace Nested Object Destruction OrderArista Networks · PHONE SCREENArista Networks interview questions
  • Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Stack Language EvaluatorRetell AI · PHONE SCREENRetell AI interview questions
  • Most Frequent Call Path in Interleaved LogsRoblox · ONSITE INTERVIEWRoblox interview questions
  • Text Editor, Part 2: Undo and RedoOpenAI · PHONE SCREENOpenAI interview questions
  • Text Document HistoryNotion · PHONE SCREEN · ONSITE INTERVIEWNotion interview questions

Interview reports that mention this question

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Question Bank: 161 Questions (Part 1 of 2)
  • Bloomberg New Grad Interviews: 2025 vs 2026 Guide
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String crushCandy(String s, int k) {
      // Write your code here.
    }
}
Checking account…