C++ solution with explanation
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)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#define ll long long \nclass Solution {\npublic:\n    // for every number we have two choose either add or subtract it\n    // if we add it will add to max of both cases addResult and subtractResult\n    // if we subtract it we want to subtract from addResult as we are trying to maximise addResult\n    long long maximumTotalCost(vector<int>& nums) {\n        ll addResult = nums[0];\n        ll subtractResult = nums[0];\n        for(int i=1;i<nums.size();i++){\n            ll a = max(addResult,subtractResult) + nums[i];\n            ll b = addResult - nums[i];\n            \n            addResult = a;\n            subtractResult = b;\n        }\n        return max(addResult,subtractResult);  \n    }\n};\n```
['Dynamic Programming', 'C++']