Final prices after next-lower-price discounts

0
Remix

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).

UberOnline assessmentLast asked Feb 2026
No answer yet. Write the first one; the best answer gets endorsed.