Find Minimum Replacements
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.
Complete the function findMinReplacements in the editor.
findMinReplacements has the following parameter:
int parcels[n]: an array representing the weights of packages.
Returns
int: the minimum number of replacements needed.
1Example 1

2Example 2
