Company: Amazon_28feb
Difficulty: medium
Code Question 1 In an Amazon Souvenir Shop, a shopper visited a souvenir shop with items arranged on the shelf from left to right. The goal is to purchase as many items as possible within a given budget. Notably, the cost of each souvenir increases with each purchase. Formally, given an array cost of size n , representing the initial cost of each item in the souvenir shop, and m representing the initial amount of money that the shopper has. The first time a souvenir is bought its cost will be cost[i] , the second time it will be 2 * cost[i] , the third time it be 3 * cost[i] and the j th time it will cost j * cost[i] and so on. The shopper will buy items one by one from left to right and when she reaches the last item she will go back to start and repeat this operation until she runs out of money. What is the number of items that the shopper will buy before she runs out of money? Example m = 18 n = 4 cost = [2, 5, 1, 1] Assuming 1-based indexing of the cost array: Item Bought Remaining