vicejuniordev
Senior Member
Python:
class Solution:
def maxSatisfied(self, c: List[int], g: List[int], m: int) -> int:
max_secret, curr, res = 0 ,0 ,0
for i in range(len(c)):
if g[i] == 0:
res += c[i]
else:
curr += c[i]
if i >= m:
curr -= c[i - m] if g[i - m] == 1 else 0
max_secret = max(max_secret, curr)
return res + max_secret