Amazon Online Assessment!

amazon logo
amazon
May 25, 20257 reads

Summary

This post describes a coding problem encountered during an Amazon Online Assessment, focusing on optimizing package delivery using drones with varying capacities and minimizing package replacements.

Full Experience

In ABC's distribution network, there are several drones with varying capacities, ranging from 1 to 10^9. Each ith drone has a carrying capacity of j. The company needs to dispatch n packages, where the weight of the ith package is given by pack[i].

During peak delivery times, only two drones are available to transport the packages, and they must alternate in their duties. This means that if Drone 1 handles the ith package, Drone 2 must handle the (i + 1)th package, and so on.

However, there may be challenges if the drones cannot handle certain package weights (i.e., some packages may be too heavy for a drone). To address this, Amazon can replace certain packages with others of a different weight to ensure that all packages are successfully delivered.

Given the ability to choose any two drones, your task is to determine the minimum number of replacements needed to ensure that all packages can be successfully delivered.

Example 1: n=4 pack=[3,1,3,2] Ans=1

Example 2: n=4 pack=[1,1,1,1] Ans=2

Interview Questions (1)

Q1
Minimum Package Replacements for Alternating Drone Delivery
Data Structures & AlgorithmsHard

In ABC's distribution network, there are several drones with varying capacities, ranging from 1 to 10^9. Each ith drone has a carrying capacity of j. The company needs to dispatch n packages, where the weight of the ith package is given by pack[i].

During peak delivery times, only two drones are available to transport the packages, and they must alternate in their duties. This means that if Drone 1 handles the ith package, Drone 2 must handle the (i + 1)th package, and so on.

However, there may be challenges if the drones cannot handle certain package weights (i.e., some packages may be too heavy for a drone). To address this, Amazon can replace certain packages with others of a different weight to ensure that all packages are successfully delivered.

Given the ability to choose any two drones, your task is to determine the minimum number of replacements needed to ensure that all packages can be successfully delivered.

Example 1: n=4 pack=[3,1,3,2] Ans=1

Example 2: n=4 pack=[1,1,1,1] Ans=2

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!