Python || O(2N) || Easy Understanding || Left and Right Scan
Intuition\n Describe your first thoughts on how to solve this problem. \nWe create two lists to track the max number for one segment from both left and right si
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe create two lists to track the max number for one segment from both left and right sides, and there are at least one value.\n```\nleft = [1] * len(p)\nright = [1] * len(p)\n```\nThen max number for two segmens on `ith` element will equal to `left[i]+right[i+1]`. \n\nLastly we can get the max number for two segments on whole array.\n\n# Code\n```\nclass Solution:\n    def maximizeWin(self, p: List[int], k: int) -> int:\n        left = [1] * len(p)\n        right = [1] * len(p)\n\n        if len(p) <= 1:\n            return 1\n        i = 0    \n        for j in range(1, len(p)):\n            while p[j] - k > p[i]:\n                i += 1\n            left[j] = max(left[j-1], j - i + 1)\n        \n        i = len(p) - 1\n        for j in range(len(p)-2, -1, -1):\n            while p[i] - k > p[j]:\n                i -= 1\n            right[j] = max(right[j+1], i - j + 1)\n\n        result = 0\n        for i in range(0, len(p)-1):\n            result = max(result, left[i]+right[i+1])\n        return result\n```
['Python3']