Longest Well-Performing Interval

We are given hours, a list of the number of hours worked per day for a given employee.

A day is considered to be a tiring day if and only if the number of hours worked is strictly greater than 8.

A well-performing interval is an interval of days for which the number of tiring days is strictly larger than the number of non-tiring days.

Return the length of the longest well-performing interval.

Example 1
Inputhours = [9,9,6,0,6,6,9]
Output3
The longest well-performing interval is [9, 9, 6].
Example 2
Inputhours = [6,6,6]
Output0
There is no interval where tiring days are strictly more numerous than non-tiring days.

Constraints

  • 1 <= hours.length <= 10^4
  • 0 <= hours[i] <= 16

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate