Easy to understand Java Solution
Intuition\nWe can simulate the process described on the problem, and keep repeating as long as our score is the same as the one from the first action.\nSo, for 
# Intuition\nWe can simulate the process described on the problem, and keep repeating as long as our score is the same as the one from the first action.\nSo, for the first 3 possible operations we compute the maximum between the next operations and use memoization to optimize the code.\n\n# Approach\nCreate dp array to store previous answer.\nCreate operations function which will go deep as long as we find the same score.\nCall operations function for the first 3 possible operations.\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(n^2)\n\n# Code\n```java []\nclass Solution {\n    int[][] dp;\n    public int maxOperations(int[] nums) {\n        dp = new int[2001][2001];\n        int n = nums.length;\n        return 1 + Math.max(operations(nums,2,n,nums[0]+nums[1]),Math.max(operations(nums,0,n-2,nums[n-1]+nums[n-2]),operations(nums,1,n-1,nums[0]+nums[n-1])));\n    }\n\n    public int operations(int[] nums, int start, int end, int score) {\n        if (end-start < 2) {\n            return 0;\n        }\n\n        if (dp[start][end-1] > 0) {\n            return dp[start][end-1];\n        }\n        int max = 0;\n        \n        if (nums[start]+nums[start+1] == score) {\n            max = Math.max(max, 1 + operations(nums,start+2,end,score));\n        }\n        if (nums[end-1]+nums[end-2] == score) {\n            max = Math.max(max, 1 + operations(nums,start,end-2,score));\n        }\n        if (nums[start]+nums[end-1] == score) {\n            max = Math.max(max, 1 + operations(nums,start+1,end-1,score));\n        }\n        dp[start][end-1]=max;\n        return max;\n    }\n}\n```
['Dynamic Programming', 'Java']