C++ (DP) Kadane Solution With Constant Space
\nNote If the array is positive we dont need any deletion.\n\n1- Every element have 2 choices Get Skipped (if no element is skipped till now) or Get Picked (if 
\n*Note If the array is positive we dont need any deletion.*\n\n1- Every element have 2 choices **Get Skipped** (if no element is skipped till now) or **Get Picked** (if any element has been skipped already).\n\n2- If an element is picked = element + Sum (including the skipped element).\n```\n// if any element is skipped before, we will pick the current element \n            int skipped_before = skipped_sum + nums[i];\n```\n3- If an element is skipped = 0 + Sum (current sum excluding the latest skipped element).\n```\n// if no element is skipped before, we will skip the current element\n            int not_skipped = curr_sum + 0;\n```\n4- After making the choice we will pick the maximum sum.\n```\n\t\tskipped_sum = max(skipped_before , not_skipped);\n```\n\n----------------------------------\n```\nclass Solution {\npublic:\n    int maximumSum(vector<int>& nums) {\n        int res = nums[0]; // total result\n        int curr_sum = nums[0]; // picking first element\n        int skipped_sum = 0; // skipping first element\n        \n        for(int i=1;i<nums.size();i++)\n        {\n            // if any element is skipped before, we will pick the current element \n            int skipped_before = skipped_sum + nums[i];\n            // if no element is skipped before, we will skip the current element\n            int not_skipped = curr_sum + 0;\n            skipped_sum = max(skipped_before , not_skipped);\n            \n            //kadane for current sum so that we don\'t have any negative sum if possible\n            if(curr_sum<0)\n            {\n                curr_sum=nums[i];\n            }\n            else\n            {\n                curr_sum=curr_sum+nums[i];\n            }\n            \n            int max_sum = max(curr_sum , skipped_sum);\n            res=max(res,max_sum);\n        }\n        \n        return res;\n    }\n};\n```\n
['Dynamic Programming', 'C', 'C++']