easy and different approach for dp
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:\nint dp[2001][2001];\nint solve(vector<int>&nums,int sum,int i,int j){\n    int a=0;   int  b=0;    int c=0;\n     if(j<0||i>=nums.size())return 0;\n\n    if(dp[i][j]!=-1)return dp[i][j];\n    if(i+1<=j&&nums[i]+nums[i+1]==sum||sum==0){\n      a= 1+  solve(nums,nums[i]+nums[i+1],i+2,j);\n    }\n  \n       if(i<j&&nums[i]+nums[j]==sum||sum==0){\n     b= 1+ solve(nums,nums[i]+nums[j],i+1,j-1);\n    }\n       if(j-1>=i&&nums[j]+nums[j-1]==sum||sum==0){\n     c= 1+   solve(nums,nums[j]+nums[j-1],i,j-2);\n    }\n    return dp[i][j]= max({a,b,c});\n\n}\n    int maxOperations(vector<int>& nums) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(nullptr);\n        memset(dp,-1,sizeof(dp));\n        return solve(nums,0,0,nums.size()-1);\n        \n    }\n};\n```
['C++']