Crush Matching Candy Runs and Drop Pieces Until the Board Settles
Last updated: November 29, 2026
Quick Overview
Given a match-three puzzle board of positive integers (0 is empty), repeatedly remove every horizontal or vertical run of three or more equal values at the same time, let pieces fall straight down to fill gaps, and return the stable board.
0
0
0 solved
Given a match-three puzzle board of positive integers (0 is empty), repeatedly remove every horizontal or vertical run of three or more equal values at the same time, let pieces fall straight down to fill gaps, and return the stable board.
A Google onsite simulation problem in the style of mobile puzzle games on Play. The interviewer checks that all matches in a round are found before anything is removed, that gravity is applied per column correctly, and that the loop terminates.
What the Interviewer Expects
- Marks all crushable cells in a round before clearing any
- Finds horizontal and vertical runs of length three or more
- Applies gravity per column with a write pointer
- Repeats until a round finds no matches
- Discusses the cost per round and why the loop ends
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Count the total score where a run of length L scores L squared.
- Bound the number of rounds in terms of the board size.
- Add new random pieces from the top after each drop.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
boardm x n of non-negative ints, 0 means empty. - One round: find every cell that belongs to a run of 3+ equal nonzero values horizontally or vertically, set all of them to 0 simultaneousl...
High-Level Design
Clearing cells as you find them would break overlapping runs (an L or T shape). So each round first builds a set of cells to crush by checking every horizontal and vertical window of three. Then zero ...