1124. Longest Well-Performing Interval Medium

@problem@discussion
#Array#Hash Table#Stack#Monotonic Stack#Prefix Sum



1/**
2 * [1124] Longest Well-Performing Interval
3 *
4 * We are given hours, a list of the number of hours worked per day for a given employee.
5 * A day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8.
6 * 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.
7 * Return the length of the longest well-performing interval.
8 *  
9 * Example 1:
10 * 
11 * Input: hours = [9,9,6,0,6,6,9]
12 * Output: 3
13 * Explanation: The longest well-performing interval is [9,9,6].
14 * 
15 * Example 2:
16 * 
17 * Input: hours = [6,6,6]
18 * Output: 0
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	1 <= hours.length <= 10^4
24 * 	0 <= hours[i] <= 16
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/longest-well-performing-interval/
30// discuss: https://leetcode.com/problems/longest-well-performing-interval/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn longest_wpi(hours: Vec<i32>) -> i32 {
36        0
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_1124() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.