CS-OA cs-vo Faang

Welcome to Amazon Student Programs Coding challenge

1. Code Question 1

The supply chain manager at one of Amazon's warehouses is shipping the last container of the day. All n boxes have been loaded into the truck with their sizes represented in the array boxes. The truck may not have enough capacity to store all the boxes, though, so some of the boxes may have to be unloaded. The remaining boxes must satisfy the condition:

max(boxes) ≤ capacity * min(boxes)

Given the array boxes, and capacity, find the minimum number of boxes that need to be unloaded.

Example:

Input:

  • n = 4
  • boxes = [1, 4, 3, 2]
  • capacity = 2

Output:

1

Explanation:

Unloading box[0] with size 1 leads to the condition max(4, 3, 2) = 4 ≤ 2 * min(4, 3, 2) = 4.
This satisfies the required condition. Hence, the answer is 1.


2. Code Question 2

Within the Amazon Gaming Distribution System, a logistics coordinator is faced with the task of 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, also no game should be 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.

What is the minimum storage capacity of pen drives that you must order to be able to give these games to the children?

Example:

Input:

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

Output:

9

Explanation:

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 2nd one to store the second and third games, and the 3rd 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.

getMinSize has the following 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 ≤ 200000
  • 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 *