Company: Amazon_6july

Difficulty: medium

Problem Statement

Maximize Dispatch Credits Problem Description A logistics company runs several warehouses, and warehouse i currently holds inventory[i] units of one product. You and a co-worker share the job of clearing these warehouses to fulfill orders, following this procedure: Starting on warehouse i , you go first and reduce its inventory by dispatch1 units. Your co-worker then takes a turn and reduces the same warehouse's inventory by dispatch2 units. You keep alternating turns on warehouse i until its inventory drops to zero or below (i.e., inventory[i] ≤ 0 ). Whenever your turn is the one that brings a warehouse's inventory to zero or below, the two of you jointly earn 1 credit. Your co-worker is allowed to skip a turn instead of dispatching, but only up to skips times in total. Work out the dispatch strategy that maximizes the combined number of credits the two of you can earn. Examples Example 1: Input: n = 6 inventory = [10, 6, 12, 8, 15, 1] dispatch1 = 2 dispatch2 = 3 skips = 3 Explanat

More Amazon_6july OA questionsInterview experiences