[Java] Kadane's algorithm - Clean code with comments and very Easy to understand
IntuitionTrack the maximum subarray sum with and without one deletion to handle all scenarios for each element.Approach
Initialize prevWithDeleted to 0 and prev
# Intuition
Track the maximum subarray sum with and without one deletion to handle all scenarios for each element.

# Approach
1. Initialize prevWithDeleted to 0 and prevNotDeleted to nums[0].
2. Set finalMax to nums[0].
3. Loop through the array starting from index 1:
    - Update prevWithDeleted as the max of prevNotDeleted or prevWithDeleted + nums[i].
    - Update prevNotDeleted as the max of prevNotDeleted + nums[i] or nums[i].
    - Calculate currMax as the max of prevWithDeleted and prevNotDeleted.
    - Update finalMax with the max of finalMax and currMax.
4. Return finalMax.

# Complexity
- Time complexity: O(n)

- Space complexity: O(1)

# Code
```java []
// Same question - 1746. Maximum Subarray Sum After One Operation
class Solution {
    public int maximumSum(int[] nums) {
        int n = nums.length;
        int prevWithDeleted = 0;//tracks the maximum sum where one deletion has occurred
        int prevNotDeleted = nums[0]; //tracks the maximum sum where no deletions have occurred
        int finalMax = nums[0];
        for(int i = 1;i<n;i++){
            prevWithDeleted = Math.max(prevNotDeleted, prevWithDeleted + nums[i]);
            prevNotDeleted = Math.max(prevNotDeleted + nums[i], nums[i]);
            int currMax = Math.max(prevNotDeleted, prevWithDeleted);
            finalMax = Math.max(finalMax, currMax);
        }
        return finalMax;
    }
}
```
['Java']