2d DP memoized solution   do upvote me   😎😎
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\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)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<long long>> dp;\n\n    long long solve(int ind, vector<int>& nums, int p) {\n        if (ind == nums.size())\n            return 0;\n\n        if (dp[ind][p] != LLONG_MIN)\n            return dp[ind][p];\n\n        long long cont, ncont;\n        if (p == 0) {\n            cont = nums[ind] + solve(ind + 1, nums, 1);\n            ncont = nums[ind] + solve(ind + 1, nums, 0);\n        } else {\n          \n                cont = (-1) * nums[ind] + solve(ind + 1, nums, 0);\n                ncont = (-1) * nums[ind] + solve(ind + 1, nums, 0);\n            \n        }\n\n        return dp[ind][p] = max(cont, ncont);\n    }\n\n    long long maximumTotalCost(vector<int>& nums) {\n        int n = nums.size();\n        dp.resize(n, vector<long long>(2, LLONG_MIN));\n\n        return solve(0, nums, 0);\n    }\n};\n\n```
['C++']