[Roblox] OA 2025 Start – 27 Feb (Generic)

Given a square matrix n × n (n is guaranteed to be odd) that contains only 0s, 1s, and 2s, in one operation, you are allowed to change the number in any cell of the matrix to a different number (0, 1, or 2). Your task is to compute the minimum number of cells that need to change for the letter Y to be written on the matrix.

The letter Y is written on the matrix if and only if:

  • All numbers on the diagonals starting from the upper-left and upper-right corners down to the center of the matrix as well as the numbers stretching down vertically from the center of the matrix are equal.
  • All other numbers that are not part of that Y should be equal and be different from the numbers that make up the Y.

Note: For a square matrix of size n × n, there are exactly 6 possible ways of writing Y on the matrix.

The cells that make up the Y letter and the cells that make up its background can be equal to:

  • (0 and 1)
  • (1 and 0)
  • (2 and 1)
  • (1 and 2)
  • (0 and 2)
  • (2 and 0) respectively.

Below, you can see an example of letter Y for a 5 × 5 matrix:

n = 5


Imagine that there are several lamps placed on a number line, each of which illuminates some segment of the line. Specifically, the lamps are represented in a two-dimensional array lamps, where the iᵗʰ lamp covers the segment from lamps[i][0] to lamps[i][1], inclusive.

Additionally, you are given a list of control points on this number line, represented by an array points. Your task is to find the number of lamps that illuminate each control point.

For each control point points[j] in the array, your task is to find the number of lamps lamps[i] which include this point within its covered segment - when points[j] lies inside the segment [lamps[i][0], lamps[i][1]].

As a result, return an array of integers, where the iᵗʰ integer corresponds to the answer for the iᵗʰ control point.

Example

For lamps = [[1, 7], [5, 11], [7, 9]] and points = [7, 1, 5, 10, 9, 15], the output should be
solution(lamps, points) = [3, 1, 2, 1, 2, 0].


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