[Goldman Sachs] OA 2025 start – 6 Apr (finance tech round)

1. Threshold Alerts

A compliance system monitors incoming and outbound calls. It sends an alert whenever the average number of calls over a trailing number of minutes exceeds a threshold. If the number of trailing minutes is precedingMinutes = 5 at time T, average the call volumes for times T-5, T-6, T-7, T-8, T-9.

Example

numCalls = [2, 2, 2, 5, 5, 5]
alertThreshold = 3
precedingMinutes = 2

No alerts are sent until at least T = 3 because there are not enough values to consider. When T = 3, the average calls = (2 + 2) ÷ 2 = 2. Average calls from T = 4 to T = 6 are 2.5, 3, and 4.5. A total of two alerts are sent during the last two periods.

Given the call volumes, determine the number of alerts sent by the end of the timeframe.

Function Description

Complete the numberOfAlerts function in the editor below.

numberOfAlerts has the following parameters:

  • int precedingMinutes: the trailing number of minutes to consider
  • int alertThreshold: the maximum number of calls allowed before triggering an alert
  • int numCalls[n]: represents the number of calls made during the ith minute

Returns:

  • int: the number of alerts sent

Constraints

  • 1 ≤ precedingMinutes ≤ n ≤ 10⁵
  • 1 ≤ alertThreshold ≤ 10⁵
  • 0 ≤ numCalls[i] ≤ 10⁴

Input Format For Custom Testing

Sample Case 0

Sample Input For Custom Testing

STDIN      Function
-----      --------
3          → precedingMinutes = 3
3          → alertThreshold = 3
8          → n = 8
1 0 1 1 0 1 10 7 → numCalls = [1, 0, 1, 1, 0, 1, 10, 7]

Sample Output

2

Explanation

No alerts are sent until T = 3. At each of these minutes since the average number of calls during the interval (T - i) to (T - 1)...

2. Minimum Moves

There is a maze in HackerPlay where children play for recreation.

The maze is represented as an (n × m) grid of cells, where each cell is either empty (denoted by 0), or contains an obstacle (denoted by 1). HackerMan is currently standing at cell (0, 0) and wishes to reach the cell (n - 1, m - 1).

For a jump parameter denoted by k, in one move, HackerMan can move to any of the following cells:

  1. (i + s, j) where 1 ≤ s ≤ k provided cell (i + s, j) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i + s - 1, j)
  2. (i - s, j) where 1 ≤ s ≤ k provided cell (i - s, j) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i - s + 1, j)
  3. (i, j + s) where 1 ≤ s ≤ k provided cell (i, j + s) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i, j + s - 1)
  4. (i, j - s) where 1 ≤ s ≤ k provided cell (i, j - s) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i, j - s + 1)

Find the minimum number of moves in which HackerMan can reach the cell (n - 1, m - 1) starting from (0, 0), or -1 if it is impossible to reach that cell.

Example

Consider n = 2, m = 2, jump parameter k = 2, and maze = [[0, 1], [0, 0]]

The maze looks like this:

0 1
0 0

The following sequence of moves gets HackerMan from (0, 0) → (1, 0) → (1, 1). Hence, HackerMan can reach the end in 2 moves, which is the minimum possible. The answer is 2.

Function Description

Complete the function getMinimumMoves in the editor below.

getMinimumMoves has the following parameters:

  • int maze[n][m]: the maze in HackerPlay where HackerMan is standing
  • int k: the maximum distance HackerMan can traverse in one move

Returns:

  • int: the minimum number of moves in which HackerMan can reach the destination cell (n - 1, m - 1)

Constraints

  • 1 ≤ n ≤ 100
  • 1 ≤ m ≤ 100
  • 1 ≤ k ≤ 100
  • Each cell of the grid contains values either 0 or 1

Input Format For Custom Testing

The first line contains an integer, n, denoting the number of rows in the maze.
The second line contains an integer, m, denoting the number of columns in the maze.
The next n lines contain m space-separated integers — the row i of the maze
The last line contains an integer, k, denoting the maximum distance HackerMan can traverse in one move.

Sample Case 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 *