1052. Grumpy Bookstore Owner Medium
1/**
2 * [1052] Grumpy Bookstore Owner
3 *
4 * There is a bookstore owner that has a store open for n minutes. Every minute, some number of customers enter the store. You are given an integer array customers of length n where customers[i] is the number of the customer that enters the store at the start of the i^th minute and all those customers leave after the end of that minute.
5 * On some minutes, the bookstore owner is grumpy. You are given a binary array grumpy where grumpy[i] is 1 if the bookstore owner is grumpy during the i^th minute, and is 0 otherwise.
6 * When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise, they are satisfied.
7 * The bookstore owner knows a secret technique to keep themselves not grumpy for minutes consecutive minutes, but can only use it once.
8 * Return the maximum number of customers that can be satisfied throughout the day.
9 *
10 * Example 1:
11 *
12 * Input: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3
13 * Output: 16
14 * Explanation: The bookstore owner keeps themselves not grumpy for the last 3 minutes.
15 * The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16.
16 *
17 * Example 2:
18 *
19 * Input: customers = [1], grumpy = [0], minutes = 1
20 * Output: 1
21 *
22 *
23 * Constraints:
24 *
25 * n == customers.length == grumpy.length
26 * 1 <= minutes <= n <= 2 * 10^4
27 * 0 <= customers[i] <= 1000
28 * grumpy[i] is either 0 or 1.
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/grumpy-bookstore-owner/
34// discuss: https://leetcode.com/problems/grumpy-bookstore-owner/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn max_satisfied(customers: Vec<i32>, grumpy: Vec<i32>, minutes: i32) -> i32 {
40 0
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_1052() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.