AMAZON Coding Question – Solved

11 Live
Drone Delivery Optimization – Amazon's Challenge In Amazon's vast distribution network, drones are essential for delivering packages. These drones have varying capacities, ranging from 1 to 10⁹. Each j-th drone has a carrying capacity of j. Problem Statement Amazon needs to dispatch n packages, where the weight of the i-th package is given by the array pack[i].During peak delivery times, only two drones are available for transport. These drones must alternate in their duties. This means: - If Drone 1 delivers the i-th package, - Then Drone 2 must deliver the (i+1)-th package, and so on. However, not all drones can carry all packages β€” some packages might be too heavy for a particular drone. To address this issue, Amazon can replace certain packages with others of a different (lighter) weight to ensure successful delivery. Task Your task is to determine the minimum number of package replacements needed, such that all packages can be successfully delivered by some pair of drones, alternating turns. You are allowed to choose any two drones with any capacity. Example n = 4 pack = [3, 1, 3, 2]

Asked in: AMAZON

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |