Problem · Array

Find Minimum Replacements

HardAmazonFULLTIMEOA
See Amazon hiring insights

Amazon relies on a network of drones, each equipped with a unique carrying limit ranging from 1 to10^9. The j-th drone can lift a max weight of j.

The company must transport n shipments, where the weight of the i-th shipment is given by parcels[i].

During peak delivery periods, only two drones are available, and they must alternate their deliveries. This means that if Drone X delivers the i-thshipment, then Drone Y must handle the (i + 1)-th, and they must continue switching back and forth.

However, some shipments may exceed a drone's capacity, making them undeliverable. To fix this, Amazon can swap certain shipments for ones with different weights to ensure that all deliveries are possible.

Given that Amazon can select any two drones for this task, determine the minimum number of replacements required to successfully deliver all shipments.

Function Description

Complete the function findMinReplacements in the editor.

findMinReplacements has the following parameter:

  1. int parcels[n]: an array representing the weights of packages.

Returns

int: the minimum number of replacements needed.

Examples
01 · Example 1
parcels = [3, 1, 3, 2]
return = 1
Example 1 illustration
02 · Example 2
parcels = [1, 1, 1, 1]
return = 2
Example 2 illustration
This test case was added on the last day of May 2025. As we can see, the explanation is currently missing. I believe we can find it somewhere on the internet oneday. But as for when and where that will be, no one knows... 🙏💚 Source image is here -
More Amazon problems
drafts saved locally
public int findMinReplacements(int[] parcels) {
  // write your code here
}
parcels[3, 1, 3, 2]
expected1
sign in to submit