Python || DP || Binary length Subarray
Consider Subarray of length 1 or 2 to maximazie your answer.\nTC : O(n)\n\nCode:\n\n\nclass Solution:\n    def maximumTotalCost(self, nums: List[int]) -> int:\n
Consider Subarray of length 1 or 2 to maximazie your answer.\nTC : O(n)\n\nCode:\n\n```\nclass Solution:\n    def maximumTotalCost(self, nums: List[int]) -> int:\n        n=len(nums)\n        @cache\n        def dp(idx):\n            if idx>=n: return 0\n            #take one length subarray\n            ans=dp(idx+1)+nums[idx]\n            #check and take two length subarray\n            if idx+1<n: ans=max(ans,dp(idx+2)+nums[idx]-nums[idx+1])\n            return ans\n        return dp(0)\n```\n
['Dynamic Programming', 'Python3']