Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the problem of Angry Bookstore owner in leetcode

Shulou Source: shulou.com Published: 2022-06-01 13:20:49 10月01日 Update

This article is to share with you about how to solve the problem of loving angry bookstore owners in leetcode. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

I. the content of the topic

The bookstore owner has a store that plans to open for customers.length minutes on a trial basis. Every minute some customers (customers [I]) enter the bookstore, and all of these customers leave at the end of that minute.

At some point, the bookstore owner gets angry. If the bookstore owner is angry at the first minute, then grumpy [I] = 1, otherwise grumpy [I] = 0. When the bookstore owner is angry, the customers in that minute will be dissatisfied, and if they are not angry, they will be satisfied.

Bookstore owners know a secret trick that can restrain their emotions and keep them from getting angry for X minutes, but they can only use it once.

Please return to this day of business, the maximum number of customers can be satisfied with the quantity.

Example:

Input: customers = [1recovery1jinjin2jiny1jiny5], grumpy = [0rectory1jin0jing1re0jing1jin0jin1], X = 3

Output: 16

Explanation:

The bookstore owner kept calm in the last three minutes.

The maximum number of satisfied customers = 1 + 1 + 1 + 1 + 7 + 5 = 16.

Tip:

one

Tags: Bookstore owner content customer problem maximum customer quantity more satisfaction article good practical one sum code idea emotion skill article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL Xiaomi NVidia Microsoft