O(N) Sliding window + DP solution
Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(n)\n- Space complexity:\n Add your space complexity here, e.g. O(n) \nO(n)\n# Code
# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n# Code\n```python3 []\nclass Solution:\n    def maximizeWin(self, prizePositions: List[int], k: int) -> int:\n        n = len(prizePositions)\n        maxes = [0] * n\n        maxes[n-1] = ans = 1\n        right = n-1\n        for left in range(n-2, -1, -1):\n            end = prizePositions[left] + k\n            while prizePositions[right] > end:\n                right -= 1\n            prizes = right - left + 1\n            maxes[left] = max(maxes[left+1], prizes)\n            ans = max(ans, prizes + (maxes[right+1] if right+1 < n else 0))\n        return ans\n\n```
['Dynamic Programming', 'Sliding Window', 'Python3']