Simple 2D dp
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\n    long long compute(int ind, int sign, vector<vector<long long>>& dp, int& N,  vector<int>& nums){\n        if(ind == N){\n            return 0;\n        }\n\n        if(dp[ind][sign] != -1)\n            return dp[ind][sign];\n\n        // take this element with prev element\n        long long ans; \n\n        ans = (sign == 1 ? nums[ind] : -1 * nums[ind]) + compute(ind + 1, 1 - sign, dp, N, nums);\n\n        // start a-new\n        ans = max(ans, nums[ind] + compute(ind+1, 0, dp, N, nums));\n\n        return dp[ind][sign] = ans;\n    }\n\n    long long maximumTotalCost(vector<int>& nums) {\n        int N = nums.size();\n        vector<vector<long long>> dp(N + 10, vector<long long>(2, -1L));\n        return compute(0, 1, dp, N, nums);   \n    }\n};\n```
['C++']