Company: Amazon_14oct
Difficulty: medium
Modified Knapsack Problem Problem Description Given n items where: The weight of the i th item is 2 i using 0-based indexing. The cost of the i th item is cost[i] . Find the minimum amount needed to purchase items whose combined weight is at least minWeight . Multiple units of an item can be purchased. Example n = 5 cost = [2, 5, 7, 11, 25] minWeight = 26 An optimal purchase strategy is: Buy 2 units at cost[0] and 3 units at cost[3] per item Total cost = 2 * 2 + 3 * 11 = 4 + 33 = 37 Total weight = (2 * 2 0 ) + (3 * 2 3 ) = 2 + 24 = 26 , which meets the minimum weight requirement. The answer is 37, representing the minimum cost to achieve the weight requirement. Function Description Complete the function getMinimunCost in the editor with the following parameters: int cost[] : the cost of each item int minWeight : the minimum combined weight of the items Returns long_int : the minimum amount needed to purchase the items Examples Example 1: Input: 5 4 3 2 1 10 2 Output: 1 Explanation: It