Let's define the diagonal neighbors of a given cell asthe surrounding cells, with precisely one cornertouching a corner of the given cell. The picture belowshows the diagonal neighbors for the A cell.
Given a board of cells containing a bubble of aspecific color, your task is to emulate a bubble-popping game. In this game, the player can click acell every turn to pop bubbles. After clicking the cell.the following happens:
1.The bubble in the clicked cell and bubbles ofthe same color among its diagonal neighborsare "popped" and removed, resulting in emptycells.
2.After bubbles are removed, the remainingbubbles in cells above the empty cells dropdown to fill all empty cells.
3.Nothing happens if the clicked cell is empty (itdoes not contain a bubble).
The input consists of two arrays:
1.An initial board of cells bubbles - amultidimensional array of integersrepresenting cells containing different coloredbubbles;
2.A set of player turns operations - 2-elementinteger arrays describing the coordinates (therow and column) of the cell that the playerclicked on during each turn.
Return the state of the game board after alloperations are processed. The output should be amultidimensional array of integers with the same sizeas bubbles , but replace the integers in all emptycells (without bubbles) with 0.
Note: You are not expected to provide the mostoptimal solution, but a solution with time complexitynot worse than 0(bubb 7es. ength2bubb1es[0]. ength2 operations. ength) willfit within the execution time limit.
represent the colors of bubbles within cells, and it isguaranteed that all cells will have bubbles initially.
Guaranteed constraints.
1 < bubbles.length < 30
1 < bubbles[o].ength < 30
1 < bubbles[i][j] < 900
linput] array.array.integer operations
An array of 2-element arrays representing the player'smoves integers represent the coordinates of the rowand column that the player has clicked on each turn.
Guaranteed constraints.
1 < operations.length < 200
operations[i].length = 2 ,
1 < operations[i][o] < bubbles .length1 < operations[i][1] < bubbles [o].length
[output] array.array.integer
Return the final state of the game board after alloperations are processed. The output should be amultidimensional array of integers with the same size asbubbles , with o representing empty cells withoutbubbles.
本次OA算法非常简单,轻松在规定时间内完成,如果有完不成的OA,害怕过不了的面试可以扫码联系我们。我们提供OA代做,VO助攻服务。