Problem · Array

Drone Delivery Route

Learn this problem
MediumAmazon logoAmazonFULLTIMENEW GRADOA
See Amazon hiring insights

Problem statement

( ദ്ദി ˙ᗜ˙ ) Special thanks to the friends who shared these fresh last-seen signals! (07-08-2026, 07-31-2026 & 08-13-2026 :D)

Amazon is expanding its next-generation drone delivery network, consisting of m hubs arranged in a circular ring. Hub 1 is adjacent to Hub m. A drone can move to either adjacent hub, and the travel time between Hub i and its neighbors is given by transitionTime[i].

1 2 3 m-1 m

Amazon receives a list of priority delivery requests, where packages must be picked up or delivered to specific hubs in a given sequence, represented by the array requestedHubs of size n.

Starting from Hub 1, calculate the minimum total travel time required for the drone to fulfill all delivery requests.

Note: Use 1-based indexing.

Function

getMinimumDroneTime(transitionTime: int[], requestedHubs: int[]) → long

Examples

Example 1

transitionTime = [3,2,1]requestedHubs = [1,3,3,2]return = 4

The drone begins its journey at Hub 1.

  1. The first hub to visit is Hub 1 itself, so it takes 0 seconds to complete this step.
  2. To move from Hub 1 to Hub 3, the drone has two possible routes:
    • Clockwise: 1 -> 2 -> 3, which takes transitionTime[1] + transitionTime[2] = 3 + 2 = 5 seconds.
    • Counterclockwise: 1 -> 3, which takes transitionTime[1] = 3 seconds.
    • The shorter route is the counterclockwise path, so the drone reaches Hub 3 in 3 seconds.
  3. The drone is already at Hub 3, so it takes 0 seconds to complete this step.
  4. To move from Hub 3 to Hub 2, the visible source shows the clockwise route 3 -> 2, which takes transitionTime[3] = 1 second.

FastPrep inferred the output 4 from the visible steps: 0 + 3 + 0 + 1 = 4. The screenshot cuts off before the official final output. If you know it, feel free to tell us and we will update it. Thanks a lot in advance! We will also improve this part if we find a clearer source later. (2026-06-24 :)

More Amazon problems

drafts saved locally
public long getMinimumDroneTime(int[] transitionTime, int[] requestedHubs) {
    // write your code here
}
transitionTime[3,2,1]
requestedHubs[1,3,3,2]
expected4
checking account