[1Sentence] Slide a window saving best solution so far, return max(sum(window) + best to the left)
Upvote if you like the simplicity\n\n\ndef maximizeWin(self, prizes: List[int], k: int) -> int:\n    bestBefore = [0] * (len(prizes) + 1)\n    bestBeforeSoFar =
# Upvote if you like the simplicity\n\n```\ndef maximizeWin(self, prizes: List[int], k: int) -> int:\n    bestBefore = [0] * (len(prizes) + 1)\n    bestBeforeSoFar = 0\n    ret = 0\n    runSum = 0\n    i, j = 0, 0\n    while j<len(prizes):\n        x = prizes[j]\n        while j<len(prizes) and prizes[j] == x:\n            runSum += 1\n            j += 1\n        while prizes[i] + k < prizes[j-1]:\n            runSum -= 1\n            i += 1  # i points to the first included price index\n        bestBeforeSoFar = max(bestBeforeSoFar, runSum)\n        bestBefore[j] = bestBeforeSoFar\n        ret = max(ret, runSum + bestBefore[i])\n    return ret\n```
['Python3']