Simple Python DP with self-explanatory code and comments
\nclass Solution:\n    def maximumSum(self, nums: List[int]) -> int:\n        # First build a list of max subarray sum (up to that number) with no deletion\n   
```\nclass Solution:\n    def maximumSum(self, nums: List[int]) -> int:\n        # First build a list of max subarray sum (up to that number) with no deletion\n        # which is just a max subarray sum problem\n        noDeletion = [nums[0]]\n        for i in range(1, len(nums)):\n            noDeletion.append(nums[i] + max(0, noDeletion[i - 1]))\n        \n        # Then build a list of max subarray sum (up to that number) with at most one deletion\n        oneDeletion = [nums[0]]\n        for i in range(1, len(nums)):\n            # for each number, to ensure there is at most one deletion, we could\n            # 1. use the one from noDelete \n            # 2. delete this number by using noDeletion[i - 1]\n            # 3. including this number with at most one delete up to last index\n            oneDeletion.append(max(noDeletion[i], noDeletion[i - 1], nums[i] + oneDeletion[-1]))\n\n        return max(oneDeletion)\n```\n\nThis solution could be further optimize to O(1) space since we are just using the last element in ```noDeletion``` or ```oneDeletion``` list.\n
['Dynamic Programming', 'Python', 'Python3']