Python 3   ||   6 lines,  dp recursion w/ caching  ||   T/S: 85% / 96%
\nclass Solution:\n    def maxOperations(self, nums: List[int]) -> int:\n\n        n = len(nums)\n\n        @lru_cache(6000)\n        def dp(i: int,j: int,targe
```\nclass Solution:\n    def maxOperations(self, nums: List[int]) -> int:\n\n        n = len(nums)\n\n        @lru_cache(6000)\n        def dp(i: int,j: int,target: int)-> int:\n\n            if j - i < 2: return (j - i == 1 and nums[i]+nums[j]==target)\n\n            return max(1+dp(i+2, j  , target) if nums[i]+nums[i+1] == target else 0,\n                       1+dp(i  , j-2, target) if nums[j]+nums[j-1] == target else 0,\n                       1+dp(i+1, j-1, target) if nums[i]+nums[j  ] == target else 0)\n          \n            \n        return 1+max(dp(2, n - 1, nums[ 0] + nums[ 1]), \n                     dp(0, n - 3, nums[-1] + nums[-2]), \n                     dp(1, n - 2, nums[ 0] + nums[-1]))\n```\n[https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-ii/submissions/1178202200/](https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-ii/submissions/1178202200/)\n\nI could be wrong, but I think that time complexity is *O*(*N*^2) and space complexity is *O*(*N*^2), in which *N* ~ `len(nums)`.
['Python3']