maximize win from two segments
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def maximizeWin(self, prizePositions: List[int], k: int) -> int:\n\n        intval=[]\n        max_before=[]\n        start=0\n        count=0\n\n        for index,pos in enumerate(prizePositions):\n            count+=1\n            while pos-k>prizePositions[start]:\n                count-=1\n                start+=1\n            intval.append((count,pos))\n            if not max_before or max_before[-1][0]<count:\n                max_before.append((count,pos))\n\n        max_sol=0\n        while intval:\n            count,pos=intval.pop()\n            while max_before and max_before[-1][-1]>=pos-k:\n                max_before.pop()\n\n            candidate=count+(0 if not max_before else max_before[-1][0])\n            max_sol=max(candidate,max_sol)\n\n        return max_sol\n\n        \n        \n```
['Python3']