Amazon 2025 ng oa -Amazon -OA ghost writing -OA help

Problem 1: Minimum Product Removal to Make Catalogue Valid

There are n products in an Amazon catalogue, where the category of the i-th product is represented by the array catalogue.

The catalogue is called valid if the number of distinct product categories in it is at most k. If the catalogue is not valid initially, then make it valid by removing some products from the catalogue.

Given n products and an array catalogue, find the minimum number of products to remove from the catalogue to make it valid.


Example:

Input:
n = 4, catalogue = [3, 3, 5, 7], k = 1

Process:
Remove elements 5 and 7 from catalogue.
Resulting array: [3, 3]
Number of distinct product categories is 1 ([3]).

Other possibilities (e.g., removing [3, 3, 5] or [3, 3, 7]) require more removals, which is not optimal.

Output:
2


Function Description:

Complete the function getMinRemoval in the editor below.

Function Signature:

def getMinRemoval(catalogue: List[int], k: int) -> int:

Parameters:

  • int catalogue[n]: The category of the products.
  • int k: The maximum number of distinct product categories.

Returns:

  • int: The minimum number of elements to remove from catalogue to make it valid.

Constraints:

  • 1 ≤ n ≤ 100,000
  • 1 ≤ k ≤ 100,000
  • 1 ≤ catalogue[i] ≤ 100,000


Problem 2: Maximum Number of Equal-Cost Packages

In Amazon's online marketplace, the inventory manager is exploring strategies to enhance product sales. The focus is on creating appealing packages that offer customers a delightful shopping experience. To achieve this, the inventory manager aims to construct packages, each containing at most 2 items, to have an equal total cost across all packages.

The total cost of a package is defined as the sum of the costs of the items contained within. Each item can be used in at most one package.


Task:

Given an array cost of size n, representing the costs of individual items, determine the maximum number of packages that can be created, such that each package adheres to:

  1. A maximum of 2 items per package.
  2. All packages have the same total cost.

Example 1:

Input:
n = 3, cost = [2, 1, 3]

Process:

  • Possible packages with total cost = 2: [2] (1 package).
  • Possible packages with total cost = 1: [1] (1 package).
  • Possible packages with total cost = 3: [3], [1, 2] (2 packages).

Output:
2 (Maximum possible packages with equal total cost).


Example 2:

Input:
n = 9, cost = [4, 5, 10, 3, 1, 2, 2, 2, 3]

Process:

  • Possible packages with total cost = 6: [4, 2], [3, 3] (2 packages).
  • Other possible total costs result in fewer packages.

Output:
2


Function Description:

Complete the function maxEqualCostPackages in the editor below.

Function Signature:

def maxEqualCostPackages(cost: List[int]) -> int:

Parameters:

  • int cost[n]: The array of item costs.

Returns:

  • int: The maximum number of packages with equal total cost.

Constraints:

  • 1 ≤ n ≤ 100,000
  • 1 ≤ cost[i] ≤ 100,000

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