We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77953bc commit 2faa84fCopy full SHA for 2faa84f
solution/1052.Grumpy Bookstore Owner/Solution.java
@@ -0,0 +1,17 @@
1
+class Solution {
2
+ public int maxSatisfied(int[] customers, int[] grumpy, int X) {
3
+ int s = 0, t = 0;
4
+ for (int i = 0, win = 0; i < customers.length; ++i) {
5
+ if (grumpy[i] == 0) {
6
+ s += customers[i];
7
+ } else {
8
+ win += customers[i];
9
+ }
10
+ if (i >= X && grumpy[i - X] == 1) {
11
+ win -= customers[i - X];
12
13
+ t = Math.max(t, win);
14
15
+ return s + t;
16
17
+}
0 commit comments