Amazon OA 90 分钟 – 亚马逊OA真题 – 一亩三分地 – OA代写 – 面试代面

Code Question 1:

Problem Statement:

Developers at Amazon are working on a prototype for a utility that compresses an n x n matrix, data, with the help of a compression rate represented by an array, factor. The utility returns an integer which is the maximum sum of exactly x elements of the matrix such that the number of elements taken from the ith row does not exceed factor[i] for all 0 ≤ i < n. The utility returns -1 if the compression cannot be performed.

Given array data and factor, find the maximum sum to perform compression under the given constraints, or -1 if it is not possible.

Example:

Given n = 3,

  • data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
  • factor = [1, 2, 1],
  • x = 2.

The best choices for each row are (3), (5, 6), and (9), respectively. Only x = 2 elements can be chosen. The maximum sum of 2 elements is data[2][2] + data[1][2] = 9 + 6 = 15. Return 15.

Code Question 2:

Problem Statement:

Within the Amazon Gaming Distribution System, a logistics coordinator is tasked with efficiently distributing a collection of n computer games among k different children. Each game is characterized by its size, denoted by gameSize[i] for 1 ≤ i ≤ n.

To facilitate the distribution process, the coordinator opts to utilize pen drives, ordering k pen drives with identical storage capacities. Each child can receive a maximum of 2 games, and every child must receive at least one game, with no game left unassigned.

Considering the impracticality of transferring large game files over the internet, the strategy involves determining the minimum storage capacity required for the pen drives. A pen drive can only store games if the sum of their sizes does not exceed the pen drive's storage capacity.

Example:

Given

  • n = 4,
  • gameSize[] = [9, 2, 4, 6],
  • k = 3.

We note that pen drives of size 9 are required to store the largest game. The minimum capacity of pen drives required is 9.

Sample Case 0:

Input:

  • 2
  • 5
  • 11
  • 1

Output:

  • 16

Explanation:

Since there is only 1 pen drive available, we need to put both games in it. Hence, the minimum size of pen drives required is 11 + 5 = 16.

Example:

Given

  • n = 4,
  • gameSize[] = [9, 2, 4, 6],
  • k = 3.

We note that we will need pen drives of the size of at least 9 units to store the first game. This also turns out to be the minimum size of pen drives that should be ordered to give the games to these children. We can use the first pen drive to store the game of size 9, the second one to store the second and third games, and the third pen drive to store the fourth game. Hence, the minimum capacity of pen drives required is 9 units.

Function Description:

Complete the function getMinSize in the editor below.
The function returns a long integer.

Parameters:

  • int gameSize[n]: the size of each game
  • int k: the number of children amongst whom the games are to be distributed

Returns:

  • int: an integer variable denoting the minimum capacity of pen drives required to distribute the games amongst the children.

Constraints:

  • 1 ≤ k ≤ n ≤ 2 * 10^5
  • 1 ≤ gameSize[i] ≤ 10^9
  • n ≤ 2 * k

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