C# - 4 liner - Single pass - No additional space - Time O(n) & Space O(1)
Idea:\nKeep track of maxSum for below 2 cases-\na) MaxSum with last element being dropped\nb) MaxSum till current element\n\nAt the end, return max of a) or b).
Idea:\nKeep track of maxSum for below 2 cases-\na) MaxSum with last element being dropped\nb) MaxSum till current element\n\nAt the end, return max of a) or b).\n\nPlease share your feedback.\n```\npublic class Solution {\n    public int MaximumSum(int[] arr)\n    {\n        int maxSumWithLastDrop = 0, maxSumTillCurrent = arr[0], maxSumTillPrev = 0, max = arr[0];\n        for (int i = 1; i < arr.Length; i++)\n        {\n            maxSumWithLastDrop = Math.Max(maxSumWithLastDrop, maxSumTillPrev) + arr[i];\n            maxSumTillPrev = maxSumTillCurrent;\n            maxSumTillCurrent = Math.Max(maxSumTillCurrent + arr[i], arr[i]);\n            max = Math.Max(max, Math.Max(maxSumTillCurrent, maxSumWithLastDrop));\n        }\n        return max;\n    }\n}\n```
[]