Approach hintTry it first, then revealHide
A day is bad exactly when a strictly smaller price appears later, that is, when its next smaller element exists. A right-to-left scan keeping the minimum seen so far settles every day in one pass.
A day is bad exactly when a strictly smaller price appears later, that is, when its next smaller element exists. A right-to-left scan keeping the minimum seen so far settles every day in one pass.