```
class Solution {
public:
int findTargetSumWays(vector<int>& nums, int S, int current_sum = 0, int index = 0) {
if(index == nums.size()){
if(current_sum == S) res++;
}else{
findTargetSumWays(nums, S, current_sum + nums[index], index+1);
findTargetSumWays(nums, S, current_sum - nums[index], index+1);
}
return res;
}
private:
int res = 0;
};
```