1
var maxSatisfied = function (customers, grumpy, minutes) {3
let maxUnsatisfied = 0;7
// finding the satisfied customers8
for (let i = 0; i < customers.length; i++) {9
if (grumpy[i] === 0) satisfied += customers[i];12
// finding the maximum un-satisfied customers within the give timeframe13
// classic sliding window approach14
for (let i = 0; i < customers.length; i++) {15
if (grumpy[i]) curr += customers[i];16
if (i - left + 1 > minutes) {17
if (grumpy[left]) curr -= customers[left];20
if (i - left + 1 === minutes) {22
maxUnsatisfied = curr;27
return satisfied + maxUnsatisfied;