Python Intuitive Top Down DP
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n**2)\n\n- Space complexity: O(n**2)\n\n# Code\n```\nclass Solution:\n    def maxOperations(self, nums: List[int]) -> int:\n        @lru_cache(None)\n        def dfs(score, lo, hi):\n            if lo >= hi:\n                return 0\n\n            maxOps1 = 1 + dfs(score, lo + 2, hi) if sum(nums[lo: lo + 2]) == score else 0\n            maxOps2 = 1 + dfs(score, lo + 1, hi -1) if (nums[lo] + nums[hi]) == score else 0\n            maxOps3 = 1 + dfs(score, lo, hi - 2) if sum(nums[hi-1:hi+1]) == score else 0\n\n            return max(maxOps1, maxOps2, maxOps3)\n            \n\n        possibleScores = {sum(nums[:2]), nums[0] + nums[-1], sum(nums[-2:])}\n        maxOps = -inf\n        for score in possibleScores:\n            maxOps = max(maxOps, dfs(score, 0, len(nums) - 1))\n        \n        return maxOps\n\n\n```
['Python3']