Most Satisfied Customers With One Calm Window

Quick Overview

Most Satisfied Customers With One Calm Window. For minute i, customers[i] customers arrive and leave that same minute.

Most Satisfied Customers With One Calm Window

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem For minute i, `customers[i]` customers arrive and leave that same minute. They are satisfied exactly when `grumpy[i]` is 0. Once during the day, the owner can suppress grumpiness for `minutes` consecutive minutes. Return the maximum total number of satisfied customers. ```cpp class Solution { public: int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes); }; ``` ### Examples **Example 1:** ```text Input: customers = [2,5,1,4], grumpy = [0,1,1,0], minutes = 2 Output: 12 Explanation: Six customers are already satisfied; calming minutes1 and2 adds5+1. ``` **Example 2:** ```text Input: customers = [3,2,4], grumpy = [1,0,1], minutes = 1 Output: 6 Explanation: The baseline is2, and calming the last minute adds4. ``` ### Constraints - The two arrays share length n. - `1 <= minutes <= n <= 20000`. - Each customer count lies in `[0,1000]`. - Each grumpy entry is 0 or 1. ### Contract considerations The technique can be used only once and its window is consecutive. ```hint Read the boundary condition Does using the technique change customers outside its selected consecutive minutes? ``` ### Boundary reminders The technique can be used only once and its window is consecutive.

Overview: Most Satisfied Customers With One Calm Window. For minute i, customers[i] customers arrive and leave that same minute.

Amazon logo
Amazon
Source window: 0–3 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

For minute i, customers[i] customers arrive and leave that same minute. They are satisfied exactly when grumpy[i] is 0. Once during the day, the owner can suppress grumpiness for minutes consecutive minutes. Return the maximum total number of satisfied customers.

class Solution {
public:
    int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes);
};

Examples

Example 1:

Input: customers = [2,5,1,4], grumpy = [0,1,1,0], minutes = 2
Output: 12
Explanation: Six customers are already satisfied; calming minutes1 and2 adds5+1.

Example 2:

Input: customers = [3,2,4], grumpy = [1,0,1], minutes = 1
Output: 6
Explanation: The baseline is2, and calming the last minute adds4.

Constraints

  • The two arrays share length n.
  • 1 <= minutes <= n <= 20000 .
  • Each customer count lies in [0,1000] .
  • Each grumpy entry is 0 or 1.

Contract considerations

The technique can be used only once and its window is consecutive.

Boundary reminders

The technique can be used only once and its window is consecutive.