11.25 Amazon Coding Challenge – 亚马逊笔试真题 – OA writing 代写 – 面试辅助 – 代面试 – VO interview support

Question 1: Code Question 1

Description:
At Amazon, a user owns a unique tool called the "Parentheses Perfection Kit." This kit contains different types of parentheses, each with a specific efficiency rating. The goal is to create a balanced sequence of parentheses by adding zero or more parentheses from the kit to maximize the sequence's total EfficiencyScore. The EfficiencyScore of a sequence is the sum of the efficiency ratings of the parentheses used from the kit.

A sequence is considered balanced if:

  • It has an equal number of opening ( and closing ) parentheses.
  • Each opening parenthesis is properly matched with a closing one in the correct order (e.g., circular balance). For example:
    • Balanced sequences: (), (()), (()()).
    • Unbalanced sequences: ((), ()), and ())(.

You are given:

  1. An initial parentheses sequence represented by the string s.
  2. A Parentheses Perfection Kit containing different types of parentheses in the form of the string kitParentheses and their respective efficiency ratings in the efficiencyRatings array (both of size m).

The EfficiencyScore of the original string s is initially 0. You can use any number of unused parentheses from the kit to create the final sequence, as long as the final sequence remains balanced.

The task is to determine the maximum possible EfficiencyScore that can be achieved for the resulting balanced sequence.

Note: It is guaranteed that the sequence can be made balanced by adding zero or more parentheses from the kit.


Example:

  • Input:s = ")(" kitParentheses = ")(())" m = 6 efficiencyRatings = [3, 4, 2, -4, -1, -3]
  • Parentheses in the user's bag and their efficiencyRatings:Type)(()))Efficiency Ratings342-4-1-3
  • Process: After adding parentheses:
    1. Add parenthesis at index 1 and 2 from kitParentheses.
    2. Final sequence: (()).
    3. EfficiencyScore: 3 + 4 + 2 = 9.
  • Output:EfficiencyScore = 9

Question 2: Code Question 2

Description:
Developers at Amazon are working on a new sorting algorithm for points on the x-axis of the coordinate system.

There are n points. The i-th point:

  1. Initially has a weight of weight[i].
  2. Is located at position i on the x-axis.

In a single operation, the i-th point can be moved to the right by a distance of dist[i].

The task is to find the minimum number of operations required to sort the points by their weights.


Example:

  • Input:n = 4 weight = [3, 6, 5, 1] dist = [4, 3, 2, 1]
  • Process:
    1. Perform operation twice on point 2, moving it by 2 * dist[1] = 6.
      • New positions: [3, 1, 5, 6].
    2. Perform operation twice on point 3, moving it by 2 * dist[2] = 4.
      • New positions: [1, 3, 5, 6].
    3. Resulting operations: 2 + 2 = 4.
  • Output:Minimum number of operations = 5

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