Very Easy & Intuitive C++ Solution Approach
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```\nclass Solution {\npublic:\n\n    int dp[2000][2000];\n\n\n    int f(vector<int> &nums, int l, int r, int sum, int n) {\n        \n        if(!(l <= r-1)) {\n            return 0;\n        }\n        if(sum == -1) {\n            return dp[l][r] =  1 + max(f(nums, l+1, r-1, nums[l]+nums[r], n), max(f(nums, l+2, r, nums[l]+nums[l+1], n), f(nums , l , r-2, nums[r]+nums[r-1], n)));\n        }\n        if(dp[l][r] != -1) {\n            return dp[l][r];\n        }\n        if(l <= r-1) {\n            if(nums[l] + nums[l+1] == sum && nums[r] + nums[r-1] == sum && nums[r] + nums[l] == sum) {\n                return dp[l][r] = 1 + max(f(nums, l+1, r-1, nums[l]+nums[r], n), max(f(nums, l+2, r, nums[l]+nums[l+1], n), f(nums , l , r-2, nums[r]+nums[r-1], n)));\n            }\n            else if((nums[l] + nums[l+1] == sum && nums[r] + nums[r-1] == sum)) {\n                return dp[l][r] = 1 + max(f(nums, l+2, r, nums[l]+nums[l+1], n), f(nums , l , r-2, nums[r]+nums[r-1], n));\n            }\n            else if(nums[r] + nums[r-1] == sum && nums[r] + nums[l] == sum) {\n                return dp[l][r] = 1 + max(f(nums, l, r-2, sum, n), f(nums , l+1 , r-1, sum, n));\n            }\n            else if(nums[l] + nums[l+1] == sum && nums[r] + nums[l] == sum) {\n                return dp[l][r] = 1 + max(f(nums, l+2, r, nums[l]+nums[l+1], n), f(nums, l+1, r-1, nums[l]+nums[r], n));\n            }\n            else if(nums[l] + nums[l+1] == sum) {\n                return dp[l][r] = 1 + f(nums, l+2, r, sum , n);\n            }\n            else if(nums[l] + nums[r] == sum) {\n                return dp[l][r] = 1 + f(nums, l+1, r-1, sum , n);\n            }\n            else if(nums[r] + nums[r-1] == sum) {\n                return dp[l][r] = 1 + f(nums, l, r-2, sum , n);\n            }\n            else{\n                return dp[l][r] = 0;\n            }\n        }\n        else{\n            return 0;\n        }\n    }\n\n    int maxOperations(vector<int>& nums) {\n       int n = nums.size();\n       memset(dp, -1, sizeof(dp));\n       return f(nums, 0, n-1, -1, n); \n    }\n};\n```
['Array', 'Dynamic Programming', 'Memoization', 'C++']