simple solution
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n\nclass Solution {\npublic:\n    int solve(int i, int j, int sum, vector<int>& nums, vector<vector<int>>& dp) {\n        if (i >= j) return 0;\n        if (dp[i][j] != -1) return dp[i][j];\n        \n        int a = 0, b = 0, c = 0;\n        \n        if (i + 1 <= j && nums[i] + nums[i + 1] == sum) {\n            a = 1 + solve(i + 2, j, sum, nums, dp);\n        }\n        if (j - 1 >= i && nums[j] + nums[j - 1] == sum) {\n            b = 1 + solve(i, j - 2, sum, nums, dp);\n        }\n        if (nums[i] + nums[j] == sum) {\n            c = 1 + solve(i + 1, j - 1, sum, nums, dp);\n        }\n        \n        return dp[i][j] = max({a, b, c});\n    }\n    \n    int maxOperations(vector<int>& nums) {\n        int n = nums.size();\n        \n        vector<vector<int>> dp1(n, vector<int>(n, -1));\n        vector<vector<int>> dp2(n, vector<int>(n, -1));\n        vector<vector<int>> dp3(n, vector<int>(n, -1));\n        \n        int a = solve(2, n - 1, nums[0] + nums[1], nums, dp1);\n        int b = solve(0, n - 3, nums[n - 1] + nums[n - 2], nums, dp2);\n        int c = solve(1, n - 2, nums[0] + nums[n - 1], nums, dp3);\n        \n        return 1 + max({a, b, c});\n    }\n};\n\n\n```
['Dynamic Programming', 'C++']