kadane's like algorithm with two sum variable , O(n) time O(1) space
\n   int maximumSum(vector<int>& arr) {\n        int sm1 = 0,sm2 = 0;\n        int ans = INT_MIN;\n        for(int nm : arr){\n             ans = max(ans,max(sm
```\n   int maximumSum(vector<int>& arr) {\n        int sm1 = 0,sm2 = 0;\n        int ans = INT_MIN;\n        for(int nm : arr){\n             ans = max(ans,max(sm1+nm,sm2+nm));\n            sm2 = max(sm2+nm, sm1);\n            sm1 += nm;\n            if(sm2<0)\n                sm2 =0;\n            if(sm1<0)\n                sm1 = 0;\n        }\n        return ans;\n    }\n\t```\n\there sm1 store max sum till index withaut excluding anything , and sm2 store max sum with 1 item excluded
[]