FastPrepPop Diagonal Chains
Problems/Pop Diagonal Chains

Pop Diagonal Chains

Capital One logoCapital One● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Capital One software engineering intern online assessment in Toronto, taken on CodeSignal, had a grid question as its third task. The report says only that clearing one number also clears linked numbers on its diagonals, and that you give back the grid at the end.

It does not say what a move looks like, what counts as linked, what a cleared cell holds, or whether numbers fall into the gaps. Here, a move names one cell. The clearing spreads in the four diagonal directions through cells with the same value and stops at the first different value. Cleared cells become 0, nothing falls, and a move on an empty cell does nothing. The limits are our choices.

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

You are given an m x n integer grid grid and a list moves, where moves[k] = [r, c] names the cell in row r and column c. Rows and columns are numbered from 0. A cell that holds 0 is empty.

Apply the moves one by one, in order. For a move at (r, c):

  • If the cell is empty, nothing happens.
  • Otherwise, let v be its value. The cell pops. Then, starting from (r, c), go in each of the four diagonal directions: up-left, up-right, down-left and down-right. In each direction, step one cell at a time. While the next cell is inside the grid and holds v, it pops too. Stop at the first cell that is outside the grid or holds a different value. An empty cell also stops the chain.
  • Every popped cell becomes 0. Nothing falls or moves into the empty cells.

Cells that touch (r, c) only by a side never pop. Return the grid after all moves.

Function

popDiagonalChains(grid: int[][], moves: int[][]) → int[][]

Examples

Example 1

grid = [[1,2,1],[2,1,2],[1,2,1]]moves = [[1,1]]return = [[0,2,0],[2,0,2],[0,2,0]]
grid
012012112122121
→
return
012002012022020
Moved or new

The move pops the 1 in the center. All four corners hold 1 and each sits right next to the center on a diagonal, so they pop too. The 2s touch the center only by a side, so they stay.

Example 2

grid = [[2,7,7,8],[7,2,8,7],[7,7,5,7],[8,7,7,2]]moves = [[0,0],[0,3]]return = [[0,7,7,0],[7,0,0,7],[7,7,5,7],[8,7,7,2]]
grid
012302778172872775738772
→
return
012300770170072775738772
Moved or new

The first move pops the 2 at (0, 0). Going down and right, (1, 1) is also 2 and pops, but (2, 2) is 5, so the chain stops there. The 2 at (3, 3) stays, because the 5 breaks the chain. The second move pops the 8 at (0, 3). Going down and left, (1, 2) is 8 and pops, then (2, 1) is 7, so the chain stops and the 8 at (3, 0) stays.

Example 3

grid = [[4,4],[4,4]]moves = [[0,0],[1,1],[0,1]]return = [[0,0],[0,0]]
grid
01044144
→
return
01000100
Moved or new

The first move pops (0, 0) and its diagonal neighbor (1, 1), giving [[0,4],[4,0]]. Nothing falls into the empty cells. The second move is on an empty cell, so nothing happens. The third move pops (0, 1) and its diagonal neighbor (1, 0), so every cell is 0.

Constraints

  • 1 <= m, n <= 50, where m is the number of rows and n is the number of columns of grid
  • 1 <= grid[i][j] <= 9
  • 1 <= moves.length <= 1000
  • moves[k].length == 2
  • 0 <= moves[k][0] < m and 0 <= moves[k][1] < n
  • Every row of grid has the same length.

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[][] popDiagonalChains(int[][] grid, int[][] moves) {
        // Write your code here.
    }
}
Checking account…