Grumpy Bookstore Owner

From Linkjob AI, 1 Week ago, written in , viewed 10 times.
URL https://stikked.quicker-app.de/view/ff40b852 Embed
Download Paste or View Raw
  1. # LC5476 Grumpy Bookstore Owner
  2.  
  3. **Approach.** Base satisfied customers + best window of recovered grumpy minutes.
  4.  
  5. ```python
  6. def maxSatisfied(c, g, m):
  7.     base = sum(x for x, y in zip(c, g) if not y)
  8.     w = best = 0
  9.     for i in range(len(c)):
  10.         w += c[i]*g[i]
  11.         if i >= m: w -= c[i-m]*g[i-m]
  12.         best = max(best, w)
  13.     return base + best
  14. ```
  15.  
  16. **Interview note.** State the invariant before coding and dry-run one edge case. For live practice, an [multilingual AI interview assistant](https://www.linkjob.ai/) can help you rehearse explanations — see https://www.linkjob.ai/ .
  17.  

Reply to "Grumpy Bookstore Owner"

Here you can reply to the paste above