Company: Visa_5_feb
Difficulty: medium
Shopping Spree Discount Shopping Spree Discount Problem Description Your task is to calculate the total cost of buying a list of items under a specific pricing rule. You are given an array of integers prices where prices[i] is the price of the i-th item. The pricing rule is as follows: The first item (at index 0) is purchased at its full price. For every subsequent item, you receive a discount. The discount is equal to the minimum price of all the items that have been purchased so far . The cost of an item is its original price minus the discount. The cost of an item cannot be negative. If the discount is greater than the price, the cost of the item is 0. Calculate and return the total cost of purchasing all the items in the list. Example 1: Input: prices = [2, 5, 1, 4] Output: 8 Explanation: First item costs 2 (no discount applies to the first item). Minimum price so far is 2. Second item costs 5 - 2 = 3 (minimum previous price was 2). Minimum price so far is min(2, 5) = 2. Third item