FastPrepCoordinate Removals with Column Gravity
Problems/Coordinate Removals with Column Gravity

Coordinate Removals with Column Gravity

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes a matrix of distinct numbers, removals given as ordered [row,column] pairs, gravity that pulls each column down, the final matrix as output, and skipping coordinates whose value was already processed. We supplied zero as empty, coordinates that change over time, filling from the top, indexing, and limits. Our version is about 90% the same as the reported question.

matrix contains distinct positive values; zero represents empty. Process zero-based [row,column] coordinates in order against the evolving matrix.

If the addressed cell is nonzero, remove it, shift every value above it down by one in that column, and set the top cell to zero. If it is already zero, skip it. Return the final matrix.

Function

removeCellsWithGravity(matrix: int[][], coordinates: int[][]) → int[][]

Examples

Example 1

matrix = [[1,2],[3,4]]coordinates = [[1,0]]return = [[0,2],[1,4]]
matrix
01012134
→
return
01002114
Moved or new

The value above falls into the removed bottom cell.

Example 2

matrix = [[1],[2],[3]]coordinates = [[0,0]]return = [[0],[2],[3]]
matrix
0011223
→
return
0001223
Moved or new

Removing the top simply replaces it with zero.

Constraints

  • 1 <= rows, columns <= 500
  • 0 <= coordinates.length <= 100000
  • Every coordinate is in bounds.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024
  • Count Case-Insensitive Key ChangesOA · Seen Sep 2024

Similar questions at other companies

  • Rotate Matrix Regions Around the DiagonalsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Rotate Matrix Regions Around the DiagonalsHudson River Trading · OAHudson River Trading interview questions
  • Robot Navigation Around LasersRoblox · OARoblox interview questions
  • Leaves Remaining After Wind GustsOpenAI · OAOpenAI interview questions
  • Apply a Reversi MoveAmazon · OA
  • Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions
  • Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Sort Every Matrix Border LayerCapital One · OACapital One interview questions
  • Rotate a Square Matrix ClockwiseVisa · OAVisa interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int[][] removeCellsWithGravity(int[][] matrix, int[][] coordinates) {
        // Write your code here.
    }

}
Checking account…