import java.util.*;
public class Solution {
public int res = 0;
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param nums int整型一维数组
* @param target int整型
* @return int整型
*/
public int findTargetSumWays (int[] nums, int target) {
// write code here
if (0 == nums.length) {
return 0;
}
process(nums, 0, 0, target);
return res;
}
public void process(int[] nums, int index, int num, int target) {
if (index >= nums.length) {
if (num == target) {
res++;
}
return;
}
process(nums, index + 1, num - nums[index], target);
process(nums, index + 1, num + nums[index], target);
}
}