FastPrepFastPrep
Problem Brief

Find Minimum Replacements

FULLTIMEOA
See Amazon online assessment and 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.

1Example 1

Input
parcels = [3, 1, 3, 2]
Output
1
Explanation
Example 1 illustration

2Example 2

Input
parcels = [1, 1, 1, 1]
Output
2
Explanation
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 -
public int findMinReplacements(int[] parcels) {
  // write your code here
}
Input

parcels

[3, 1, 3, 2]

Output

1

Sign in to submit your solution.