[roblox] OA 2025 start – 28 Apr (general)

Problem 1

For a grid of black and white cells with rows rows and cols columns, you're given an array black that contains the [row, column] coordinates of all the black cells in the grid.

Your task is to compute how many 2 x 2 submatrices of the grid contain exactly blackCount black cells, for each 0 ≤ blackCount ≤ 4. As a result, you will return an array of 5 integers, where the i-th element is the number of 2 x 2 submatrices with exactly i black cells.

It is guaranteed that black cell coordinates in the black array are pairwise unique, so the same cell is not colored twice.

Example

  • For rows = 3, cols = 3, and black = [[0, 0], [0, 1], [1, 0]], the output should be
solution(rows, cols, black) = [1, 2, 0, 1, 0]

Explanation

Grid:
1 1 0
1 0 0
0 0 0
  • black cells in the 2x2 submatrix:
0 1 2 3 4
0 2 0 1 0

Problem 2

Given a matrix of integers, with each element containing either 0, 1, or 2, your task is to find the longest diagonal segment which matches the following pattern: 1, 2, 0, 2, 0, 2, 0, ... (where the first element is 1, and then 2 and 0 are repeating infinitely), and finishes at a matrix border. Return the length of this diagonal segment.

The diagonal segment:

  • May start at any matrix element
  • May go toward any possible diagonal direction
  • Must end at an element in the first or last row or column

Example

  • For
matrix = [
  [0, 0, 1, 2],
  [0, 2, 2, 2],
  [2, 1, 0, 1]
]

the output should be

solution(matrix) = 3

Explanation

Matrix:
0 0 1 2
0 2 2 2
2 1 0 1

我们长期稳定承接各大科技公司如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.

Leave a Reply

Your email address will not be published. Required fields are marked *