Final prices after next-lower-price discounts
You get a list of prices. Each item is discounted by the first later price that is lower than it (agree whether an equal price counts); an item with no such price pays full price. Return the total cost.
Brute force passes; a monotonic stack makes it O(n).
No answer yet. Write the first one; the best answer gets endorsed.
