Striver's appraoch take or nottake for beginners!!!!
Intuition\nThe intution is simple just here I have just taken the index which represents the maximum value of cost and boolean flag represents the state wether 
# Intuition\nThe intution is simple just here I have just taken the index which represents the maximum value of cost and boolean flag represents the state wether we have to multipy the nums[ind] by 1 or -1.\n\n# Approach\nHere as you can see that I have taken a 2d dp array.\nIn the find function, if we reach the base case then we will return 0.\nNow there I have taken two cases, old and new_val, ie, we can either continue with the old subarray or start a new one.\nNow if we decide to continue with old subrray then we have two cases, \nwether to multiply nums[ind] by 1 or -1 depending on the value of flag.\nIf the flag is true it means multiply nums[ind] by 1 otherwise -1.\nOr we can decide to discard the current subarray and then then continue with a new subarray.\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\nMemoisation code\n```\nclass Solution {\n    using ll = long long;\n    ll find(int ind, const vector<int>& nums, bool flag, vector<vector<ll>>& dp) {\n        if (ind == (int)nums.size()) return 0;\n        if (dp[ind][flag] != LLONG_MIN) return dp[ind][flag];\n        ll old = 0;\n        if (flag) {\n            old = nums[ind] + find(ind + 1, nums, false, dp);\n        } else {\n            old = -(nums[ind]) + find(ind + 1, nums, true, dp);\n        }\n        ll new_val = nums[ind] + find(ind + 1, nums, false, dp);\n        return dp[ind][flag] = max(old, new_val);\n    }\npublic:\n    long long maximumTotalCost(vector<int>& nums) {\n        int n = nums.size();\n        vector<vector<ll>> dp(n + 1, vector<ll>(2, LLONG_MIN)); \n        return find(0, nums, true, dp);\n    }\n};\n\n```\nTabulation Code \n```\nclass Solution {\n    using ll = long long;\npublic:\n    long long maximumTotalCost(vector<int>& nums) {\n        int n = nums.size();\n        vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));\n        for (ll ind = n - 1; ind >= 0; ind--) {\n            for (ll flag = 1; flag >= 0; flag--) {\n                ll old = 0;\n                if (flag) {\n                    old = nums[ind] + dp[ind + 1][0];\n                } else {\n                    old = -(nums[ind]) + dp[ind + 1][1];\n                }\n                ll new_val = nums[ind] + dp[ind + 1][0];\n                dp[ind][flag] = max(old, new_val);\n            }\n        }\n        return dp[0][1];\n    }\n};\n\n```
['Dynamic Programming', 'Memoization', 'C++']