Pop Matching Balloon Neighborhoods
Updated
Problem statement
Positive integers are balloon colors and zero is empty. Evaluate one simultaneous popping round. A nonzero center triggers when at least two of its orthogonal neighbors have the same color; pop the center and every same-colored orthogonal neighbor of every triggering center.
After all pops, compact surviving balloons toward larger row indices within each column, preserving their order. Return the result.
Function
popBalloons(grid: int[][]) → int[][]Examples
Example 1
grid = [[0,1,0],[1,1,1],[0,2,0]]return = [[0,0,0],[0,0,0],[0,2,0]]Moved or new
The center and its three matching neighbors pop before gravity.
Example 2
grid = [[1,1],[2,3]]return = [[1,1],[2,3]]One matching neighbor is insufficient.
Constraints
1 <= rows, columns <= 2000 <= grid[r][c] <= 1000000000
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
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · 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