Beginner friendly approach...Take Not take approach using DP
Intuition\n Describe your first thoughts on how to solve this problem. \nAssume u have taken the 1st element\nnow u can include the 2nd element as part of 1st e
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAssume u have taken the 1st element\nnow u can include the 2nd element as part of 1st element subarray if u multiply it with negative sign\nor\nu can make the 2nd element a new subarray if u dont multiply it with negative sign\n\nFor example:\n[1,-2,-7]\nhere we can take [1]\nnext [1,-(-2)] or [1][-2]\nnext A: [1,2,-7] or B: [1][-2,(-(-7))] or C: [1][-2][-7]\nchoose the maximum one\nA:-4 | B:1+(-2+7) = 6 |  C:(1)+(-2)+(-7) = -8\n\nSo B is the ans which is 6.\n \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N^2)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(2*N)\n\n# Code\n```\nclass Solution {\n    long[][] dp;\n    public long maximumTotalCost(int[] nums) {\n        dp = new long[nums.length][2];\n        for (long[] i : dp){\n            Arrays.fill(i,-1);\n        }\n        return find(nums,0,0);\n    }\n    private long find(int[] nums,int ind,int sign){\n        if (ind == nums.length)return 0;\n        if (dp[ind][sign] != -1)return dp[ind][sign];\n        long ans = Long.MIN_VALUE;\n        if (sign == 0){\n            long newsub = nums[ind] + find(nums,ind+1,0);\n            long samesub = nums[ind] + find(nums,ind+1,1);\n            ans = Math.max(ans,Math.max(newsub,samesub));\n        }\n        else{\n            long samesub = -nums[ind] + find(nums,ind+1,0);\n            ans = Math.max(ans,samesub);\n            \n        }\n        \n        return dp[ind][sign] = ans;\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']