Solved LeetCode program · 842 of 1,000
#1124 · Longest Well-Performing Interval
Original English source
The hours is a list of 9, 9, 6, 0, 6, 6, and 9. The count is 7. The offset is count. The earliest is a list of 15 zeros.
For every spot from 0 to 14.
Set item spot of earliest to -2.
The score is 0. The best is 0.
For every spot from 0 to count minus 1.
The value is item spot of hours. If value is more than 8, add 1 to score, otherwise subtract 1 from score. The length is 0. If score is more than 0, set length to spot plus 1. The prior is score minus 1 plus offset. The seen is -2. If prior is at least 0, set seen to item prior of earliest. If score is at most 0 and seen is not -2, set length to spot minus seen. If length is more than best, set best to length. The here is score plus offset. If item here of earliest is -2, set item here of earliest to spot.
Show best.
Expected stdout
3