Search
⌘K

Leetcode 1124. Longest Well-Performing Interval

Convert days to +1 (hours>8) and -1 (hours<=8) and find the longest contiguous subarray whose sum is >0. This reduces to finding the farthest pair of prefix sums with a positive difference, solvable in O(n) using prefix-sum techniques (monotonic stack or hashmap).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.