Final Prices With a Special Discount in a Shop
Easy · Stack & Monotonic Stack · about 10 minutes
Asked at Uber, Microsoft, Meta, Google, Amazon.
prices[i] is the price of item i. Buying item i gives a discount equal to prices[j], where j is the first index after i with prices[j] <= prices[i] (no discount if there's none). Return the final price of every item.