Clean solution
Intuition\n Describe your first thoughts on how to solve this problem. \ndon\'t rely on the test set, maybe the test set will give you some misunderstanding.\n\
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ndon\'t rely on the test set, maybe the test set will give you some misunderstanding.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\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```\n/*\n  addSum\n  subSum\n*/\n\nfunction maximumTotalCost(nums: number[]): number {\n  let addSum = nums[0], subSum = nums[0];\n\n  nums.forEach((n, i) => {\n    if (i === 0) return;\n    const tempAdd = Math.max(addSum + n, subSum + n);\n    subSum = addSum - n;\n    addSum = tempAdd;\n\n  })\n\n  return Math.max(addSum, subSum);\n};\n\n```
['TypeScript']