C++ |  Clean
Intuition\n Describe your first thoughts on how to solve this problem. \nRecursion + memoization \n# Approach\n Describe your approach to solving the problem. \
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nRecursion + memoization \n# Approach\n<!-- Describe your approach to solving the problem. -->\nDP\n\n# Complexity\n- Time complexity: O(N^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int dp[2001][2001]={0};\n    int sameScore(vector<int>& nums,int i,int j,int score)\n    {\n        if(i>=j)return 0;\n        \n        if(dp[i][j]!=0)return dp[i][j];\n        \n        int opt1=0;\n        int opt2=0;\n        int opt3=0;\n        \n        if(score==-1)\n        {\n            opt1=sameScore(nums,i+2,j,nums[i]+nums[i+1]) +1;\n            opt2=sameScore(nums,i+1,j-1,nums[i]+nums[j]) +1;\n            opt3=sameScore(nums,i,j-2,nums[j]+nums[j-1]) +1;\n        }\n        else\n        {   \n            if(nums[i]+nums[i+1]==score)opt1=sameScore(nums,i+2,j,nums[i]+nums[i+1]) +1;\n            if(nums[i]+nums[j]==score) opt2=sameScore(nums,i+1,j-1,nums[i]+nums[j]) +1;\n            if(nums[j]+nums[j-1]==score)opt3=sameScore(nums,i,j-2,nums[j]+nums[j-1]) +1;\n        }\n        return dp[i][j]=max({opt1,opt2,opt3});\n    }\n    int maxOperations(vector<int>& nums) {\n        \n        return sameScore(nums,0,nums.size()-1,-1);\n    }\n};\n```
['C++']