Simple recursion + memo
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 maximumTotalCost(vector<int>& nums) {\n        vector<long long> memo(nums.size() * 2 + 1, LONG_MIN);\n        return dfs(nums, 0, 1, memo);\n    }\n    \n    long long dfs(vector<int>& nums, int i, int sign, vector<long long> &memo) {\n        if (i == nums.size()) return 0;\n        int key =  nums.size() -  sign * i;\n        if (memo[key] != LONG_MIN) return memo[key];\n        long long res = 0;\n        res += sign * nums[i];\n        long long cut = dfs(nums, i + 1, 1, memo);\n        long long dontCut = dfs(nums, i + 1, sign * -1, memo);\n        memo[key] = res + max(cut, dontCut);\n        return memo[key];     \n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'C++']