JAVA MEMO EASY SOLUTION USER FRIENDLY>>>
Intuition\n Describe your first thoughts on how to solve this problem. \nIt is the simple DP Memoization Approach, Here in this case we can take or not-take the
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIt is the simple DP Memoization Approach, Here in this case we can take or not-take the next element of the array,If we don\'t take the next element,means it is not a subarray, so start from the next element to find a subarray. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIf we take the element of this Array, We take a multi variable where the initial **multi=-1**, \n  We mulitiply the multi to **-1**, And also add the **nums[i]*(-multi)** which give me the negative next element and adding to the existing subarray, making the subarray sum. \n   Now Atlast we do the **max(take,ntake)** to get the maximum total cost. \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    Here the Time Complexity is O(n^2)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n   Here the Time Complexity is O(n^2), Using The 2D Dp memoization.\n# Code\n```\nclass Solution {\n    public long maximumTotalCost(int[] nums) {\n        int n=nums.length;\n        long dp[][]=new long[n][3];\n        for(int i=0;i<n;i++){\n            for(int j=0;j<3;j++){\n                dp[i][j]=-1;\n            }\n        }\n        return maximum(nums,0,-1,n,dp);\n    }\n    public long maximum(int nums[],int i,int multi,int n,long dp[][]){\n        if(i>=n) return 0;\n        if(dp[i][multi+1]!=-1) return dp[i][multi+1];\n        long ntake=maximum(nums,i+1,-1,n,dp)+(long)nums[i];\n        long take=maximum(nums,i+1,-1*multi,n,dp)+(long)nums[i]*(-multi);\n        return dp[i][multi+1]=(long)Math.max(ntake,take);\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']