[Stackline] OA 2025 Start – 02 Feb (Generic)

You are given an array of positive integers numbers, and a number range represented by an array nRange consisting of two positive integers nRange[0] and nRange[1].

Return the lowest value in numbers which explicitly falls between the number range (excluding the endpoints) – i.e., nRange[0] < number < nRange[1]. If there is no such value, return 0.

Note:

You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(numbers.length²) will fit within the execution time limit.

Example:

For numbers = [11, 4, 23, 9, 10] and nRange = [5, 12], the output should be
solution(numbers, nRange) = 9.

Explanation:

  • numbers[0] = 11, numbers[3] = 9, and numbers[4] = 10 are the only values which are greater than 5 and less than 12.
  • Since 9 < 10 < 11, the answer is 9.

For numbers = [1, 3, 2] and nRange = [1, 1], the output should be
solution(numbers, nRange) = 0.

Explanation:

  • An integer value cannot be greater than 1 and less than 1 at the same time, so the answer is 0.

You have been tasked with ensuring the integrity of sensor data used in a real-time monitoring system. Occasionally, sensors produce readings with consecutive duplicate digits that need to be corrected.

Given a string of space-separated numbers sensorReadings, identify each number with at least two consecutive duplicate digits. For each of these numbers, replace it with the sum of its digits. Return the modified string with the numbers separated by spaces in their original order.

Note:

You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(sensorReadings.length²) will fit within the execution time limit.

Example:

For sensorReadings = "123 4558 787", the output should be
solution(sensorReadings) = "123 22 787".

Explanation:

  • The number 4558 has consecutive duplicate digits 5. The sum of digits in 4558 is 4 + 5 + 5 + 8 = 22, so it is replaced with 22.
  • The number 787 has duplicate digits 7, but they are not consecutive, so it remains unchanged.

For sensorReadings = "123456789", the output should be
solution(sensorReadings) = "123456789".


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