CS-OA cs-vo Faang

Amazon latest OA – Amazon OA 真题 – 亚马逊OA 真题

Amazon的OA近期更新了,本次的第二条超难

1. Code Question 1

A user is using the Amazon fitness tracker, and they are engaged in a jumping exercise routine. The user is positioned on the ground, and there are nnn stones, each placed at different heights. The height of the iii-th stone is represented by height[i] meters.

The goal is to maximize the calorie burn during this exercise, and the calories burned when jumping from the iii-th stone to the jjj-th stone is calculated as:(height[i]−height[j])2(\text{height}[i] - \text{height}[j])^2(height[i]−height[j])2

The user intends to practice jumping on each stone exactly once but can choose the order in which they jump. Since the user is looking to optimize their calorie burn for this single session, the task is to determine the maximum amount of calories that can be burned during the exercise.

Formally, given an array height of size nnn, representing the height of each stone, find the maximum amount of calories the user can burn.

Note that the user can jump from any stone to any stone, and the ground's height is 0. Once the user jumps to a stone from the ground, they can never go back to the ground.

Example:

n = 3
height = [5, 2, 5]

The user will jump in the following way:

  • Ground → 3rd stone → 2nd stone → 1st stone

The calories they will burn can be calculated as:

It can be shown it is not possible to burn more than 43 units of calories; hence, the answer is 43.


Function Description

Complete the function findMaximumCalories in the editor below.

  • findMaximumCalories has the following parameters:
    • int height[n]: the height of each stone

Code Question 2

Amazon's warehouse management team is planning to roll out certain standards and checks that every Amazon Warehouse Manager will follow. Some products may need to be moved initially from one warehouse to another so that each warehouse complies.

A warehouse stores identical containers arranged in the form of a circle. The distance between two adjacent containers is 1. Each container in a warehouse should hold the same number of products. Plan the optimal set of movements under the following rules:

  • Move products from any location in either the clockwise or the anti-clockwise direction. The direction must remain the same throughout the remaining moves.
  • While moving, collect excess products from some locations and deliver them to other locations that need more units.
  • The cost of each product transfer is the distance the product is moved.
  • The total cost is the sum of the costs for all products transferred.

Find the minimum cost such that finally, every container has the same number of products.

Note: In the examples, positions are one-indexed. It is guaranteed that it is always possible to distribute the products equally.

Example:

Consider a circular arrangement of containers. The units in each container are products = [3, 4, 6, 6, 6].

Position 1 → 3 products
Position 2 → 4 products
Position 3 → 6 products
Position 4 → 6 products
Position 5 → 6 products

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