```
void calculate(int*, int, int, int, int*, int);
int findTargetSumWays(int* nums, int numsSize, int S) {
int count = 0;
calculate(nums, 0, 0, S, &count, numsSize);
return count;
}
void calculate(int* nums, int i, int sum, int S, int* count, int size) {
if (i == size) {
if (sum == S) {
*count+=1;
}
} else {
calculate(nums, i + 1, sum + nums[i], S, count, size);
calculate(nums, i + 1, sum - nums[i], S, count, size);
}
}
```