FastPrepCandy Crush Board Until Stable
Problems/Candy Crush Board Until Stable

Candy Crush Board Until Stable

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report directly gives a one-dimensional crush example and asks for the two-dimensional Candy Crush follow-up at the idea level. It omits the board contract, simultaneous marking, gravity, and repetition rules; this practice version uses the standard stable-board simulation, matching the visible follow-up at about 45%.

Given a non-empty rectangular integer matrix board, crush candies until nothing more can be crushed, and return the stable board. A positive value is a candy type, and 0 is an empty cell.

Each round works like this:

  1. Find every horizontal or vertical run of at least three adjacent cells with the same positive value. Find all runs on the board as it is at the start of the round, so overlapping horizontal and vertical runs are crushed at the same time.
  2. Set every matched cell to 0.
  3. In each column on its own, the non-zero values fall to the bottom and keep their top-to-bottom order. Zeros fill the cells left at the top.

Repeat rounds until the board is stable, meaning no run is left.

Function

candyCrushBoard(board: int[][]) → int[][]

Examples

Example 1

board = [[110,5,112,113,114],[210,211,5,213,214],[310,311,3,313,314],[410,411,412,5,414],[5,1,512,3,3],[610,4,1,613,614],[710,1,2,713,714],[810,1,2,1,1],[1,1,2,2,2],[4,1,4,4,1014]]return = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[110,0,0,0,114],[210,0,0,0,214],[310,0,0,113,314],[410,0,0,213,414],[610,211,112,313,614],[710,311,412,613,714],[810,411,512,713,1014]]
board
01234011051121131141210211521321423103113313314341041141254144515123356104161361467101271371478101211811222941441014
→
return
01234000000100000200000311000011442100002145310001133146410002134147610211112313614871031141261371498104115127131014
Moved or new

The first round crushes the runs near the bottom. After the candies fall, four new horizontal runs line up, and the second round crushes them. After that, no horizontal or vertical run of length three is left, so this board is returned.

Example 2

board = [[1,2,3],[4,5,6],[7,8,9]]return = [[1,2,3],[4,5,6],[7,8,9]]
board
012012314562789
→
return
012012314562789

The board is already stable, so it is returned unchanged.

Example 3

board = [[1,2,1],[2,2,2],[1,2,1]]return = [[0,0,0],[1,0,1],[1,0,1]]
board
012012112222121
→
return
012000011012101
Moved or new

The middle row and the middle column are both runs, and they share the center cell. All five matched cells are crushed together, then the four corner candies fall to the bottom of their columns.

Constraints

  • 1 <= board.length, board[r].length <= 50.
  • Every row has the same length.
  • 0 <= board[r][c] <= 2000.
  • A match contains at least three equal positive values and is horizontal or vertical.

More Bloomberg LP Onsite Interview questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Spiral MatrixAthenahealth · ONSITE INTERVIEW
  • Spiral MatrixNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Incremental Hard Attention with a KV CacheOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Stochastic Gradient Descent with MomentumMeta · ONSITE INTERVIEWMeta interview questions
  • Minesweeper Board UpdateUber · ONSITE INTERVIEWUber interview questions
  • Game of Life: In-Place Next GenerationGoogle · ONSITE INTERVIEWGoogle interview questions
  • Diagonal Matrix IteratorMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Game of Life Next GenerationTemporal · ONSITE INTERVIEWTemporal interview questions
  • Minesweeper Board UpdateClay · ONSITE INTERVIEW
  • Minesweeper Board UpdateAirbyte · ONSITE INTERVIEW

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)

Bloomberg LP interview experiences

  • 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 Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[][] candyCrushBoard(int[][] board) {
        // Write your code here.
    }

}
Checking account…