public int helper(int[] nums, int begin, int end) {
        if (begin + 1 >= end)
            return nums[begin];
        int[] dp = new int[end - begin + 1];
        dp[0] = nums[begin];
        dp[1] = Math.max(nums[begin], nums[begin + 1]);
        for (int i = 2; i < end - begin + 1; ++i) {
            dp[i] = dp[i - 2] + nums[begin + i];
            dp[i] = Math.max(dp[i], dp[i - 1]);
        }
        return dp[end - begin];
    }