Easy c++ DP solution
Intuition\n\n\n\n# Approach\n\n\n\n# Complexity\n- Time complexity:\no(n)^2\n\n- Space complexity:\n Add your space complexity here, e.g. O(n) \no(n)^2\n\n# Cod
# Intuition\n\n\n\n# Approach\n\n\n\n# Complexity\n- Time complexity:\no(n)^2\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\no(n)^2\n\n# Code\n```\nclass Solution {\npublic:\n    int dp[2001][2001];\n\n    int solve(vector<int>& nums, int i, int j, int s) {\n       \n        if (i >= j) return 0;\n\n        if (dp[i][j] != -1) return dp[i][j];\n\n        int a = 0, b = 0, c = 0;\n\n        if ((nums[i] + nums[i + 1] == s || s == -1)) {\n            a = solve(nums, i + 2, j, nums[i] + nums[i + 1]) + 1;\n        }\n\n        if ((nums[j] + nums[j - 1] == s || s == -1)) {\n            b = solve(nums, i, j - 2, nums[j] + nums[j - 1]) + 1;\n        }\n\n        if ((nums[i] + nums[j] == s || s == -1)) {\n            c = solve(nums, i + 1, j - 1, nums[i] + nums[j]) + 1;\n        }\n\n        return dp[i][j] = max(a, max(b, c));\n    }\n\n    int maxOperations(vector<int>& nums) {\n        memset(dp, -1, sizeof(dp));\n        int n = nums.size();\n\n        return solve(nums, 0, n - 1, -1);\n    }\n};\n\n```
['C++']