Question: Bubble Popping Game
Problem Statement
Given a board of cells containing bubbles of specific colors, your task is to emulate a bubble-popping game. In this game, the player can click a cell every turn to pop bubbles. After clicking a cell, the following happens:
- The bubble in the clicked cell and bubbles of the same color among its diagonal neighbors are "popped" and removed, resulting in empty cells.
- After bubbles are removed, the remaining bubbles in cells above the empty cells drop down to fill all empty cells.
- Nothing happens if the clicked cell is empty (it does not contain a bubble).
Input
- Two arrays:
- An initial board of cells: a multidimensional array of integers representing cells containing bubbles of different colors.
- A set of player turns: 2-element integer arrays describing the coordinates (the row and column) of the cell that the player clicked on during each turn.
Output
- The state of the game board after all moves are processed. The output should be a multidimensional array of integers with the same size as the initial board. Replace the integers in all empty cells (without bubbles) with
0
.
Notes
- You are not expected to provide the most optimal solution, but a solution with time complexity not worse than
bubbles[0].length * bubbles.length
will fit within the execution time limit.
Question: Segments After Destruction
Problem Statement
Given an array of houses houses = [1, 2, 3, 7, 8, 10, 11]
and an array of queries like q = [2, 10, 8]
, return an array representing how many segments exist after each query.
Details
- Each query indicates the house that will be destroyed.
- The queries are executed in order.
- A segment is defined as a contiguous group of undestroyed houses.
Input
houses
: An array of integers representing the positions of houses.q
: An array of integers representing the queries, where each query corresponds to a house to be destroyed.
Output
- An array where each element corresponds to the number of segments left after processing each query.
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.