Recursion -> memoization || Python code
\n# Code\n\nclass Solution:\n    def asd(self,i,nums,parity,dp):\n        if(i>=len(nums)):\n            return 0\n        if(dp[i][parity]!=-1):\n            r
\n# Code\n```\nclass Solution:\n    def asd(self,i,nums,parity,dp):\n        if(i>=len(nums)):\n            return 0\n        if(dp[i][parity]!=-1):\n            return dp[i][parity]\n        add=nums[i]\n        if(parity==1):\n            dp[i][parity]=self.asd(i+1,nums,0,dp)-nums[i]\n        else:\n            dp[i][parity]=max(self.asd(i+1,nums,1-parity,dp)+nums[i],self.asd(i+1,nums,parity,dp)+nums[i])\n        return dp[i][parity]\n        \n        \n        \n    def maximumTotalCost(self, nums: List[int]) -> int:\n        # ans=0\n        # start=0\n        # for i in range(len(nums)):\n        #     if()\n        dp=[]\n        for i in range(len(nums)):\n            a=[]\n            for j in range(2):\n                a.append(-1)\n            dp.append(a)\n        p=self.asd(0,nums,0,dp)\n        # print(dp)\n        return p     \n```
['Recursion', 'Memoization', 'Python3']