Max Cost of Alt Subarrays
\n# Code\n\nclass Solution {\npublic:\nlong long maximumTotalCost(vector<int>& nums){\n\n    int n = nums.size();\n    vector<vector<long long>> Dp(n,vector<lon
\n# Code\n```\nclass Solution {\npublic:\nlong long maximumTotalCost(vector<int>& nums){\n\n    int n = nums.size();\n    vector<vector<long long>> Dp(n,vector<long long>(2));\n\n    Dp[0][0] = nums[0];\n    Dp[0][1] = nums[0];\n\n    if(n == 1){\n        return Dp[0][0];\n    }\n\n    Dp[1][0] =  nums[1] + max(Dp[0][0],Dp[0][1]);\n    Dp[1][1] = -nums[1] + Dp[0][0];\n\n    for(int i = 2;i < n;i++){\n        Dp[i][0] = nums[i] + max(Dp[i-1][1],Dp[i-1][0]);\n        Dp[i][1] = -nums[i] + Dp[i-1][0] ;\n    }\n\n    for(int i = 0;i < n;i++){\n        cout << Dp[i][0] << " " << Dp[i][1];\n        // nline\n    }\n\n    return max(Dp[n-1][0],Dp[n-1][1]);\n\n}\n\n\n\n\n};\n```
['C++']