Candy Crush
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an m x n grid board of positive integers, where each value is a candy type and 0 means an empty cell. Stabilize the board by repeating the following steps until nothing changes:
1. **Find**: mark every non-empty cell that belongs to a horizontal or vertical line of **three or more** adjacent cells with the same candy type. All lines are found at the same time, before anything is removed, and a cell may belong to several lines.
2. **Crush**: set every marked cell to 0.
3. **Drop**: in each column, let the remaining candies fall straight down so all non-zero values sit at the bottom, keeping their top-to-bottom order; empty cells collect at the top.
When a find step marks nothing, return the board.
Examples
Constraints
- `m == board.length`, `n == board[i].length`
- `3 <= m, n <= 50`
- `1 <= board[i][j] <= 2000`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.