Grumpy Bookstore Owner LeetCode solution in Java
1class Solution {2public int maxSatisfied(int[] customers, int[] grumpy, int minutes) {3int start = -1;4int count = 0;56int max = 0;7int curr = 0;89for (int i = 0; i < customers.length; i++) {10if (grumpy[i] == 0) {11count += customers[i];12} else {13curr += customers[i];14}1516if (i - start > minutes) {17start++;18if (grumpy[start] == 1) {19curr -= customers[start];20}21}22max = Math.max(max, curr);23}2425return count + max;26}27}