Using DP approach of Kadane-algorithm
Approach\nforward[i]=maximum sum of subarray which start at anywhere between 0 and i and ends at i\nbackward[i]=maximum sum of subarray which starts at i and en
# Approach\nforward[i]=maximum sum of subarray which start at anywhere between 0 and i and ends at i\nbackward[i]=maximum sum of subarray which starts at i and ends at anywhere between i and n-1\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumSum(vector<int>& arr) {\n        int n=arr.size();\n        int forward[n],backward[n];\n        forward[0]=arr[0];\n        backward[n-1]=arr[n-1];\n\n        for(int i=1;i<n;i++){\n            forward[i]=max(forward[i-1]+arr[i],arr[i]);\n        }\n         for(int i=n-2;i>=0;i--){\n            backward[i]=max(backward[i+1]+arr[i],arr[i]);\n        }\n        int ans=*max_element(forward,forward+n);\n        for(int i=1;i<n-1;i++){\n            ans=max(ans,forward[i-1]+backward[i+1]);\n        }\n        return ans;\n        \n    }\n};\n```
['C++']