Amazon aws oa 记录 – 一亩三分地 – 亚麻oa – oa代谢写 – oa writing

Code Question 1

A new Amazon intern encountered a challenging task. Currently, the intern has n integers, where the value of the iᵗʰ element is represented by the array element values[i].
The intern is curious to play with arrays and subsequences and thus asks you to join him.
Given an integer, array values, and an integer k, the intern needs to find the maximum and minimum median overall subsequences of length k.

Example:
Given n = 3, values = [1, 2, 3], and k = 2.
Subsequences of length k and their medians:

  • [1, 2] → 1
  • [1, 3] → 1
  • [2, 3] → 2

Here, the maximum median present is 2 and the minimum median in the subsequence present is 1.

Code Question 2

Amazon Kindle has several e-books that customers can purchase directly.

There are n books ordered sequentially numbered 1, 2, .., n, where the iᵗʰ book has a cost of cost[i]. A customer wants to purchase all the books, and Kindle offers the customer a unique discount to minimize their total cost.
The discount is described as follows:

  1. Let the leftmost book remaining in the sequence be book i. The customer can choose to buy the leftmost book individually for cost[i]. This book is then removed from the sequence.
  2. Let the rightmost book remaining in the sequence be book j. The customer can choose to buy the rightmost book individually for cost[j]. This book is then removed from the sequence.
  3. The customer can also choose to pay the amount pairCost for both the leftmost and rightmost books together. In this case, both the leftmost and rightmost books are removed. This option can be used as many as k times.

Given the cost of books cost, the cost to purchase the leftmost and rightmost books together, pairCost, and the maximum number of times the pairCost option can be applied k, find the minimum cost in which the customer can purchase all the books following the discount strategy above.

Example
Consider the number of books to be n = 3, their cost to be cost = [1, 2, 3], the pair cost to be pairCost = 2, and the maximum third option operations to be k = 1.
All books are purchased optimally as follows.

The minimum cost to purchase the books is 1 + 2 = 3. Thus, the answer is 3.

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