dp || c++ || 2D DP
Intuition\ndekhlo code accha se intutively likhe hai\n\n# Code\n\nclass Solution {\npublic:\nlong long dp[100001][2];\nlong long f(vector<int>&nums,int flag,int
# Intuition\ndekhlo code accha se intutively likhe hai\n\n# Code\n```\nclass Solution {\npublic:\nlong long dp[100001][2];\nlong long f(vector<int>&nums,int flag,int ind){\n    if(nums.size()<=ind)return 0;\n    if(dp[ind][flag]!=-1)return dp[ind][flag];\n    long long split=0,skip=0;\n    if(flag==0)\n    split=1LL*nums[ind]+f(nums,0,ind+1);\n    else\n    split=-nums[ind]*1LL+f(nums,0,ind+1);\n  \n    if(flag==1)\n    skip=-nums[ind]*1LL+f(nums,0,ind+1);\n    else\n    skip=nums[ind]*1LL+f(nums,1,ind+1);\n    return dp[ind][flag]=max(split,skip);\n}\n    long long maximumTotalCost(vector<int>& nums) {\n        memset(dp,-1,sizeof(dp));\n        return f(nums,0,0);\n    }\n};\n```
['C++']