✅Easy C++ Solution || Dynamic Programming
\n\n# Code\n\nclass Solution {\npublic:\n    int calculate(vector<int>& a, int i, int j, int s,vector<vector<int>>& memo) {\n        if (j <= i)\n            re
\n\n# Code\n```\nclass Solution {\npublic:\n    int calculate(vector<int>& a, int i, int j, int s,vector<vector<int>>& memo) {\n        if (j <= i)\n            return 0;\n        if (memo[i][j]!=-1) {\n            return memo[i][j];\n        }\n\n        int d = 0;\n\n        if (s == 0 || (s == a[i] + a[i + 1])) {\n            d = max(d, 1 + calculate(a, i + 2, j, a[i] + a[i + 1], memo));\n        }\n\n        if (s == 0 || (s == a[i] + a[j])) {\n            d = max(d, 1 + calculate(a, i + 1, j - 1, a[i] + a[j], memo));\n        }\n\n        if (s == 0 || (j >= 1 && s == a[j - 1] + a[j])) {\n            d = max(d, 1 + calculate(a, i, j - 2, a[j] + a[j - 1], memo));\n        }\n        return memo[i][j] = d;\n    }\n\n    int maxOperations(vector<int>& nums) {\n        vector<vector<int>> memo(nums.size(),vector<int>(nums.size(),-1));\n        return calculate(nums, 0, nums.size() - 1, 0, memo);\n    }\n};\n```
['Memoization', 'C++']