Easy DP Soln!
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public void fun(int[][] dp){
         for(int[] a : dp){
            Arrays.fill(a, -1);
        }
    }
    public int func(int i, int j, int target, int[] nums, int[][] dp){
        if(i >= j) return 0;
        if(dp[i][j] != -1) return dp[i][j];
        int ans = 0;
        if((nums[i] + nums[i+1]) == target){
            ans = 1 + func(i+2, j, target, nums, dp);
        }
        if((i+1 != j) && (nums[j] + nums[j-1] == target)){
            ans = Math.max(ans, 1 + func(i, j-2, target, nums, dp));
        }
        if((i+1 != j) && (nums[i] + nums[j]) == target){
            ans = Math.max(ans, 1 + func(i+1, j-1, target, nums, dp));
        }
        return dp[i][j] = ans;
        
    }
    public int maxOperations(int[] nums) {
        int[][] dp = new int[nums.length][nums.length];
       fun(dp);
        int ans = func(0, nums.length-1, nums[0]+nums[1], nums, dp);
        fun(dp);
        ans = Math.max(ans, func(0, nums.length-1, nums[0]+nums[nums.length-1], nums, dp));
        fun(dp);
        ans = Math.max(ans, func(0, nums.length-1, nums[nums.length-2]+nums[nums.length-1], nums, dp));
        return ans;
    }
}
```
['Dynamic Programming', 'Java']