Best sales run: hints, no solution

Easy · 1-D dynamic programming

A market stall records its total sales for each day. A rising run is a stretch of consecutive days in which every day's sales are strictly higher than the day before it. Return the number of days in the longest rising run. A single day is a run of length 1, and an empty record has no runs, so return 0. Equal sales on neighbouring days end a run.

Examples

Input
sales = [3, 5, 8, 8, 9, 12, 15, 4]
Output
4
Note
The days with sales 8, 9, 12 and 15 form the longest rising run.
Input
sales = [9, 7, 7]
Output
1
Note
No day is higher than the one before it.
Input
sales = [2, 4, 6, 8, 10]
Output
5

Constraints

  • 0 <= sales.length <= 250000
  • 0 <= sales[i] <= 1000000

Hint 1: a nudge

Suppose you already know the length of the best rising run that ends on yesterday. What does that tell you about the run that ends today?

Unlock the full hints and timed practice with a pass

The second and third hints and the timed, runner-checked practice are part of a pass.

See pricing

Sign in

Check my resume first