C++ Recursion, Memoization , Tabulation  ✅
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\n**Recursion**\n```\nclass Solution {\npublic:\n    \n    long long fun(vector<int>& nums,int i, long long sum,int pow)\n    {\n        if(i>=nums.size())\n        {\n            return sum;\n        }\n        \n        long long cut = fun(nums,i+1,sum+nums[i] * pow, 1);\n\n        long long notcut = fun(nums,i+1,sum+nums[i] * pow,-1*pow);\n        \n        \n        return max(cut,notcut);\n        \n    }\n    \n    long long maximumTotalCost(vector<int>& nums) {\n        \n        int pow=1;\n    \n        long long sum=0;\n        \n        return fun(nums,0,sum,pow);\n        \n    }\n};\n```\n\n**Memoization**\n```\nclass Solution {\npublic:\n    \n    long long fun(vector<int>& nums,int i,int pow,vector<vector<long long>>& dp)\n    {\n        if(i>=nums.size())\n        {\n            return 0;\n        }\n        \n        if (dp[i][pow == 1 ? 0 : 1] != -1) {\n            return dp[i][pow == 1 ? 0 : 1];\n        }\n        \n        long long cut = fun(nums,i+1, 1,dp)+ nums[i] * pow;\n\n        long long notcut = fun(nums,i+1,-1*pow,dp)+nums[i] * pow;\n        \n        \n        return dp[i][pow == 1 ? 0 : 1] = max(cut, notcut);\n        \n    }\n    \n    long long maximumTotalCost(vector<int>& nums) {\n        \n        int pow=1;\n    \n        long long sum=0;\n        \n        vector<vector<long long>> dp(nums.size(), vector<long long>(2, -1));\n        \n        \n        long long temp =  fun(nums,0,pow,dp);\n\n        \n        return temp;\n    }\n};\n```\n\n**Tabulation**\n```\nclass Solution {\npublic:\n        long long maximumTotalCost(vector<int>& nums) {\n        int n = nums.size();\n        vector<vector<long long>> dp(n + 1, vector<long long>(2, 0));\n\n         for(int i=0;i<nums.size();i++){\n            dp[i][0]=nums[i];\n            if(i-1>=0){\n                dp[i][0]+=max(dp[i-1][0],dp[i-1][1]);\n                dp[i][1]=-nums[i];\n                dp[i][1]+=dp[i-1][0];\n            }else{\n                dp[i][1]=nums[i];\n            }\n        }\n        return max(dp[n-1][0], dp[n-1][1]);\n    }\n};\n```\n
['Dynamic Programming', 'Recursion', 'Memoization', 'C++']