Company: Microsoft_17july
Difficulty: medium
Calculate Amount Problem Description Priya is buying a set of items at a stall. The stall owner discounts every item after the first by the lowest marked price seen among the items purchased before it. No item's price can be discounted below 0, and the order of items in the list may not be changed. Calculate the amount Priya must pay. The first item is never discounted and the minimum cost of any item is 0. Complete the function calculateAmount in the editor below. The function must return Priya's total cost to purchase all the items. calculateAmount has the following parameter(s): int prices[n] : the original prices of each of the items selected Returns: long int : the total cost to purchase the items after any discounts are applied Examples Example 1: Input: prices = [2, 5, 1, 4] Output: 8 Explanation: prices[0] = 2 . cost[0] = 2 because the first item is never discounted. prices[1] = 5 . The minimum prior price is prices[0] = 2 . So, cost[1] = 5 - 2 = 3 . prices[2] = 1 . The minimum