🔥🔥JAVA🔥🔥 Beats 100% || Easiest solution explained
Approach\nThe forward pass calculates the maximum sum of subarrays ending at each position, while the backward pass calculates the maximum sum of subarrays star
# Approach\nThe forward pass calculates the maximum sum of subarrays ending at each position, while the backward pass calculates the maximum sum of subarrays starting at each position.\n\nFinally, I iterate from the second element to the second-to-last element to consider deleting one element. The maximum sum is updated if the sum of the subarray before and after the deleted element is greater than the current maximum.\n# Complexity\n- Time complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    public int maximumSum(int[] nums) {\n        int n = nums.length;\n        int[] f = new int[n];\n        int[] b = new int[n];\n        int maxSum = nums[0];\n        // Forward pass\n        f[0] = nums[0];\n        for (int i = 1; i < n; i++) {\n            f[i] = Math.max(nums[i], f[i - 1] + nums[i]);\n            maxSum = Math.max(maxSum, f[i]);\n        }\n        // Backward pass\n        b[n - 1] = nums[n - 1];\n        for (int i = n - 2; i >= 0; i--) {\n            b[i] = Math.max(nums[i], b[i + 1] + nums[i]);\n        }\n        // Find maximum sum considering deleting one element\n        for (int i = 1; i < n - 1; i++) {\n            maxSum = Math.max(maxSum, f[i - 1] + b[i + 1]);\n        }\n        return maxSum;\n    }\n}\n\n```
['Java']