Java recursion+MAPS
\nclass Solution {\n    Map<String,Integer> map=new HashMap<>();\n    public int maxOperations(int[] nums) {\n        return f(nums,0,nums.length-1,0);\n    }\n
```\nclass Solution {\n    Map<String,Integer> map=new HashMap<>();\n    public int maxOperations(int[] nums) {\n        return f(nums,0,nums.length-1,0);\n    }\n    public int f(int[] nums,int ind1,int ind2,int prev){\n        if(ind1>=ind2) return 0;\n        int max=0;\n        String val=ind1+","+ind2+","+prev;\n        if(map.containsKey(val)){\n            return map.get(val);\n        }\n        int fsum=nums[ind1]+nums[ind1+1];\n        if(prev==0 || fsum==prev){\n            max=Math.max(max,1+f(nums,ind1+2,ind2,fsum));\n        }\n        int lsum=nums[ind2]+nums[ind2-1];\n        if(prev==0 || lsum==prev){\n            max=Math.max(max,1+f(nums,ind1,ind2-2,lsum));\n        }\n        int wsum=nums[ind1]+nums[ind2];\n        if(prev==0 || wsum==prev){\n            max=Math.max(max,1+f(nums,ind1+1,ind2-1,wsum));\n        }\n        map.put(val,max);\n        return max;\n    }\n}\n```
['Recursion', 'Memoization', 'Java']