Leetcode Weekly Contest 138 - 1052. Grumpy Bookstore Owner
Problem Today, the bookstore owner has a store open for customers.length minutes. Every minute, some number of customers ( customers[i] ) enter the store, and all those customers leave after the end of that minute. On some minutes, the bookstore owner is grumpy. If the bookstore owner is grumpy on the i-th minute, grumpy[i] = 1 , otherwise grumpy[i] = 0 . When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise they are satisfied. The bookstore owner knows a secret technique to keep themselves not grumpy for X minutes straight, but can only use it once. Return the maximum number of customers that can be satisfied throughout the day. How to solve Brute force Simply go through the customer array and whenever the owner is grumpy, check whether it's possible to use X here. Of course this won't be accepted (Time Limit Exceeded). Two pass To improve on the previous solution...
