FastPrepCrush Runs of Equal Numbers
Problems/Crush Runs of Equal Numbers

Crush Runs of Equal Numbers

Capital One logoCapital One● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2022 Capital One report from a TDP software engineer candidate in New York names one coding question: clear groups of matching neighboring numbers out of a 2D grid. It does not say which interview step asked it.

It gives no rule for how many numbers count as a group, what happens to the gaps, or whether to repeat. Here a group is three or more equal numbers in a row or column, all groups are cleared at once, the numbers above fall down into the gaps, cleared cells become 0, and this repeats until nothing more clears. The board size and value limits are also our choice.

Our version is about 55% the same as the reported question.

board is a grid of positive whole numbers. Treat 0 as an empty cell. Repeat these steps until a pass clears nothing:

  1. Look along each row and each column for three or more cells in a row with the same non-zero number. Mark every cell of each such stretch; one cell may belong to a row stretch and a column stretch at once.
  2. Clear every marked cell at the same time by setting it to 0.
  3. In each column, let the remaining numbers fall down so that all empty cells are at the top. The numbers keep their order.

Return the final board.

Function

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

Examples

Example 1

board = [[6,1,2,7],[3,3,3,5],[6,4,4,5],[9,8,4,5]]return = [[0,0,0,0],[6,1,2,0],[6,4,4,0],[9,8,4,7]]
board
012306127133352644539845
→
return
012300000161202644039847
Moved or new

Row 1 holds 3, 3, 3 in columns 0 to 2, and column 3 holds 5, 5, 5 in rows 1 to 3. Both runs are cleared at the same time. Then the numbers above each gap move down: 6 and 1 and 2 drop one row, and 7 drops three rows to the bottom of column 3.

After the drop, column 2 reads 0, 2, 4, 4 from the top. No row or column has three equal numbers in a row any more, so the board is final.

Example 2

board = [[2,5,7],[9,5,1],[5,5,5],[3,8,4]]return = [[0,0,0],[2,0,7],[9,0,1],[3,8,4]]
board
0120257195125553384
→
return
0120000120729013384
Moved or new

The 5s form an upside-down T: row 2 has 5, 5, 5, and column 1 has 5, 5, 5 in rows 0 to 2. Cell (2, 1) is in both lines and is cleared once. In columns 0 and 2, the two numbers above row 2 drop by one. Column 1 keeps only the 8 at the bottom.

Example 3

board = [[1,2,7],[4,2,8],[7,3,5],[2,9,5],[8,8,5]]return = [[0,0,0],[1,2,0],[4,2,0],[7,3,0],[2,9,7]]
board
01201271428273532954885
→
return
01200001120242037304297
Moved or new

Pass 1 clears the three 5s at the bottom of column 2. The 7 and 8 above them fall three rows, so the bottom row becomes 8, 8, 8.

Pass 2 clears that new row, and every column drops by one. Pass 3 finds no line of three, so the board is final.

Constraints

  • 3 <= board.length <= 50
  • 3 <= board[i].length <= 50, and every row has the same length.
  • 1 <= board[i][j] <= 2000

More Capital One Online Assessment questions

  • Branch with the Most FilesOA · Seen Nov 2026
  • Earliest Meeting Time for All EmployeesOA · Seen Nov 2026
  • Earn the Most 🐝OA · Seen Nov 2026
  • Rank Football TeamsOA · Seen Oct 2026
  • Count Subarrays Matching a Comparison PatternOA · Seen Oct 2026
  • Arithmetic Triplets After QueriesOA · Seen Oct 2026
  • Count One-Swap Number PairsOA · Seen Oct 2026
  • Distinct Values on Maximum-Sum FramesOA · Seen Oct 2026
  • Sort Adjacent PairsOA · Seen Oct 2026
  • Bouncing Diagonal WeightsOA · Seen Oct 2026

Similar questions at other companies

  • Maximum Diamond SumHudson River Trading · OAHudson River Trading interview questions
  • Robot Navigation Around LasersRoblox · OARoblox interview questions
  • Apply a Reversi MoveAmazon · OA
  • Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Rotate a Square Matrix ClockwiseVisa · OAVisa interview questions
  • Sort Concentric Matrix Borders ClockwiseByteDance · OAByteDance interview questions
  • Sparse Valid Conv2D From ScratchNVIDIA · OANVIDIA interview questions
  • Rotate the Box and Drop the StonesZipRecruiter · OAZipRecruiter interview questions
  • 2048 Move SimulatorBenchling · OABenchling interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public int[][] candyCrush(int[][] board) {
        // Write your code here.
    }
}
Checking account…