Company: Amazon_12june

Difficulty: medium

Problem Statement

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] . 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, your task is to calculate the minimum total travel time required for the drone to fulfill all delivery requests. Note: Use 1-based indexing. Example m = 3 n = 4 transitionTime = [3, 2, 1] requestedHubs = [1, 3, 3, 2] The drone begins its journey at Hub 1. The first hub to visit is Hub 1 itself, so it takes 0 seconds to complete this step. 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

More Amazon_12june OA questionsInterview experiences