No extra conditions || Tricky memoize || very simple || c++
Code\n\nclass Solution {\npublic:\n    int n;\n    int dp[2001][2001][3];\n    unordered_map<int,int> indices;\n    int solve(vector<int>& nums,int l,int r,int 
# Code\n```\nclass Solution {\npublic:\n    int n;\n    int dp[2001][2001][3];\n    unordered_map<int,int> indices;\n    int solve(vector<int>& nums,int l,int r,int score){\n        if(r <= l) return 0;\n        if(dp[l][r][indices[score]]!=-1) return dp[l][r][indices[score]];\n        int ret = 0 ;\n        if(score == nums[l]+nums[r]) ret = max(ret,1+solve(nums,l+1,r-1,score));\n        if(score == nums[l]+nums[l+1]) ret = max(ret,1+solve(nums,l+2,r,score));\n        if(score == nums[r]+nums[r-1]) ret = max(ret,1+solve(nums,l,r-2,score));\n        return dp[l][r][indices[score]] = ret;\n    }\n    int maxOperations(vector<int>& nums) {\n        memset(dp,-1,sizeof(dp));\n        n = nums.size();\n        int ans = 0;\n        int l =0 , r = n-1;\n        indices[nums[0]+nums[1]] = 0;\n        indices[nums[n-1]+nums[n-2]] = 1;\n        indices[nums[0]+nums[n-1]] = 2;\n        ans = max(ans,1+solve(nums,l+2,r,nums[0]+nums[1]));\n        ans = max(ans,1+solve(nums,l,r-2,nums[n-1]+nums[n-2]));\n        ans = max(ans,1+solve(nums,l+1,r-1,nums[0]+nums[n-1]));\n        return ans;\n    }\n};\n```
['C++']