Beats 100% users solution || Prefix and suffix Array || C++ || O(N) ||
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int maximumSum(vector<int>& arr) {

        if(arr.size() == 1)return arr[0];

        int res = INT_MIN;  
        int n = arr.size();

        vector<int> forward(n), backward(n);
        int maxi = arr[0], ans = maxi;
        forward[0] = arr[0], backward[n-1] = arr[n-1];

        for(int i = 1; i < n; i++){
            maxi = max(maxi + arr[i], arr[i]);
            forward[i] = maxi;
        }
        cout << endl;

        maxi = arr[n-1], ans = maxi;
        for(int i = n-2; i >= 0; i--){
            maxi = max(maxi + arr[i], arr[i]);
            backward[i] = maxi;
        }

        for(int i = 0; i < n-2; i++){
            ans = max({ans, forward[i], forward[i] + backward[i+2]});
        }

        ans = max({ans, forward[n-1], forward[n-2]});
        return ans;
    }
};
```
['C++']