Amazon OA part1 – 70mins – 亚马逊OA 真题 – 一亩三分地 – OA 代写 – 不会写OA怎么办?

1. Code Question 1

Problem Statement: Amazon Prime Games is designing a game. The player needs to pass n rounds sequentially in this game. Rules of play are as follows:

  1. The player loses power[i] health to complete round i.
  2. The player's health must be greater than 0 at all times.
  3. The player can choose to use armor in any one round. The armor will prevent damage of min(armor, power[i]).

Determine the minimum starting health for a player to win the game.

Example:

  • power = [1, 2, 6, 7]
  • armor = 5

Explanation: Give the player 12 units of health at the beginning of the game. One of the optimal strategies is to use the armor in the third round and only lose 1 unit instead of 6. The health of the player after each round is:

RoundHealthCalculation
012Starting health
11112 - power[0] = 12 - 1 = 11
2911 - power[1] = 11 - 2 = 9
389 - power[2] + armor = 9 - 6 + 5 = 8
418 - power[3] = 8 - 7 = 1

No lower starting health will allow a win.

Function Description: Complete the function getMinimumValue in the editor below.

Function Signature:

int getMinimumValue(int[] power, int armor)

Returns:

  • int: The minimum starting health required.

2. Code Question 2

Problem Statement: The developers at Amazon are working on optimizing their database query times. There are n host servers, where the throughput of the ith host server is given by host_throughput[i].

These host servers are grouped into clusters of size three. The throughput of a cluster, denoted as cluster_throughput, is defined as the median of the host_throughput values of the three servers in the cluster. Each host server can be part of at most one cluster, and some servers may remain unused.

The total system throughput, called system_throughput, is the sum of the throughputs of all the clusters formed. The task is to find the maximum possible system_throughput.

Note:

  • The median of a cluster of three host servers is the throughput of the 2nd server when the three throughputs are sorted in either ascending or descending order.

Example:

  • n = 5
  • host_throughput = [2, 3, 4, 3, 4]

Explanation: The maximum number of clusters that can be formed is 1, and two host servers will remain unused.

One possible cluster is to select the 1st, 3rd, and 5th host servers. The cluster_throughput of [2, 4, 4] will be 4 (the median value). Thus, the system_throughput for all clusters will be 4.

Function Description: Complete the function getMaxThroughput in the editor below.

Function Signature:

long getMaxThroughput(int[] host_throughput)

Returns:

  • long: The maximum system throughput.

Constraints:

  1. 1 ≤ n ≤ 2 * 10^5
  2. 1 ≤ host_throughput[i] ≤ 10^9

CSOAhelp长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

CSOAhelp 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 *