Loading...
Loading...
You are given two integer arrays customers and mood, both of length n, and an integer k. On minute i, customers[i] people arrive at the store. Each of these people is satisfied if mood[i] = 1, and unsatisfied if mood[i] = 0.
Consider an operation where you choose one contiguous stretch of k minutes and set mood[i] = 1 for every minute i in that stretch.
Given that you can perform this operation exactly once, return the maximum total number of satisfied people across all n minutes.
You can assume every value in mood is either 0 or 1.
Input: customers = [5,1,0,8,2], mood = [1,0,1,0,1], k = 2
Output: 15
Explanation: Choosing the stretch of minutes 2 and 3 sets mood[2] and mood[3] to 1. The people already satisfied at minutes 0 and 4 total 5 + 2 = 7, and the people at minutes 2 and 3 that become satisfied total 0 + 8 = 8, for 7 + 8 = 15. No other stretch of length 2 captures more unsatisfied people than the 8 arriving at minute 3.
Input: customers = [2,3,1], mood = [0,0,0], k = 3
Output: 6
Explanation: Since k equals the length of customers, the single stretch covers every minute, so every person becomes satisfied: 2 + 3 + 1 = 6.
customers.length = mood.lengthcustomers[i] ≤104mood[i] is either 0 or 1