```
public class Solution {
public int findTargetSumWays(int[] nums, int S) {
return helper(nums, S, 0);
}
private int helper(int[] nums, int target, int pos) {
if (pos == nums.length) {
if (target == 0) return 1;
return 0;
}
int count = 0;
count += helper(nums, target + nums[pos], pos + 1);
count += helper(nums, target - nums[pos], pos + 1);
return count;
}
}
```