AMAZON Coding Question – Solved

2 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

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |