C++ || Easy Solution using DP
Intuition\n\nWe can see that once we pick a sum, all operations after that must match that sum. We only have 3 initial options for the operation and so we only 
# Intuition\n\nWe can see that once we pick a sum, all operations after that must match that sum. We only have 3 initial options for the operation and so we only have 3 possible sums.\n\nGiven an array and a target sum, we can test all three possibilities for the next operation and then recursively solve the remaining array after the deletions. For a particular starting sum, the inputs to the recursive call which varry are only the starting and ending points of the remaining array, so we can memoize this result in n^2 memory and time.\n\n# Approach\nCalculate the 3 possible sums and then recursively check the most operations that can be done with that particular sum.\n\n# Complexity\nTime complexity: O(n^2) \nSpace complexity: O(n^2)\n\n# Code\n```\nclass Solution {\n    \n    int n  , sum = 0;\n    \n    int Solve(int  i , int j , vector<int>& nums , vector<vector<int>> &dp){\n        if(i>= j)\n            return 0;\n        if(dp[i][j] != -1)\n            return dp[i][j];\n        \n        int ans = 0 ;\n        if(sum == nums[i]+nums[i+1])\n            ans  = max(ans, 1 + Solve(i+2, j , nums, dp));\n        if(sum == nums[i]+nums[j])\n            ans  = max(ans, 1 + Solve(i+1, j-1 , nums, dp));\n        if(sum == nums[j-1]+nums[j])\n            ans  = max(ans, 1 + Solve(i, j-2 , nums, dp));\n        \n        return dp[i][j] = ans;\n        \n    }\n       \n    \npublic:\n    int maxOperations(vector<int>& nums) {\n        n = nums.size() ;\n        vector<vector<int>> dp(n, vector<int> (n , -1));\n        \n        sum = nums[0]+nums[1] ;\n        int op1 = Solve(2, n-1, nums, dp);\n        \n        sum = nums[0]+nums[n-1] ;\n        dp = vector<vector<int>> (n, vector<int> (n, -1));\n        int op2 = Solve(1, n-2, nums, dp );\n        \n        sum = nums[n-2]+nums[n-1] ;\n        dp = vector<vector<int>> (n, vector<int> (n, -1));\n        int op3 =  Solve(0, n-3, nums, dp);\n        \n        return 1+max(op1 , max(op2 , op3));\n    }\n};\n```
['C++']