Share my 10 line solution with O(n) time and O(1) space
preMax: maximum subarray sum, same as greedy solution from: https://leetcode.com/problems/maximum-subarray/solution/\n\npreD1Max: previous maximum sum that alre
**preMax**: maximum subarray sum, same as greedy solution from: https://leetcode.com/problems/maximum-subarray/solution/\n\n**preD1Max**: previous maximum sum that already has one deletion;\n\nThe idea is the current sum ending at index i is either preMax without adding arr[i] (which means one deletion) or preD1Max + arr[i] which also meets the rule (one deletion);\n\nOne trick here is to update preD1Max first as it uses preMax.\n```\nvar maximumSum = function(arr) {\n    let preMax = arr[0], preD1Max = arr[0];\n    let res = arr[0];\n    arr.map((c, i) => {\n        if (i === 0) return;\n\t\tpreD1Max = Math.max(preMax, preD1Max + c);\n\t\tpreMax = Math.max(preMax + c, c);\n\t\tres = Math.max(preD1Max, preMax, res);\n    })\n    return res;\n};\n```
[]