Problem Brief
Bubble Popping Game
FULLTIMEOA
You are given a 2D array grid, where grid[i][j] represents the color of the bubble at position (i, j). You are also given an operations array, which is a sequence of coordinates indicating where to pop bubbles.
Rules:
1Example 1
Input
grid = [[1, 2, 3], [6, 1, 2], [1, 2, 5]], operations = [[1, 1], [1, 2]]
Output
[[0, 0, 0], [0, 0, 3], [6, 2, 5]]
Explanation
Step 1: Pop bubble at (1, 1)
- Pops the bubble itself
- Pops diagonally connected bubble (0, 0) because it has the same color 1
[
[0, 0, 3],
[0, 2, 2],
[6, 2, 5]
]
Step 2: Pop bubble at (1, 2)
- Pops the bubble itself
- Pops diagonal (0, 1) because it's 2
- Pops diagonal (2, 1) because it's also 2
[
[0, 0, 0],
[0, 0, 3],
[6, 2, 5]
]
Final Output:
[
[0, 0, 0],
[0, 0, 3],
[6, 2, 5]
]