Stock Span
Learn Stock Span (Stack, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
The Stock Span Problem For each day's stock price, the "span" is how many CONSECUTIVE days (ending today, going backward) had a price ≤ today's price. This is Previous Greater Element in disguise: the span is the distance back to the nearest previous day with a STRICTLY GREATER price (or back to the start, if none).