EASY C++ SOLUTION || MEMORISATION || 2D DP
EASY C++ SOLUTION || MEMORISATION\n# Intuition\n Describe your first thoughts on how to solve this problem. \nreally easy and understandable\n# Approach\n Descr
EASY C++ SOLUTION || MEMORISATION\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nreally easy and understandable\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    int f(int i,int j,vector<int>& nums,int sum, vector<vector<int>>&dp){\n        if(i>j)return 0;\n        if(dp[i][j]!=-1)return dp[i][j];\n        int l=0;\n        if(i+1<=j){\n            int ss=nums[i]+nums[i+1];\n            if(sum==0 || ss==sum)l=1+f(i+2,j,nums,ss,dp);\n        }\n         int r=0;\n        if(i<=j-1){\n            int ss=nums[j]+nums[j-1];\n            if(sum==0 || ss==sum)r=1+f(i,j-2,nums,ss,dp);\n        }\n         int m=0;\n        if(i!=j){\n            int ss=nums[i]+nums[j];\n            if(sum==0 || ss==sum)m=1+f(i+1,j-1,nums,ss,dp);\n        }\n        return dp[i][j]=max(l,max(r,m));\n    }\n    int maxOperations(vector<int>& nums) {\n        int n=nums.size();\n        vector<vector<int>>dp(n,vector<int>(n,-1));\n        return f(0,n-1,nums,0,dp);\n    }\n};\n```
['C++']