class Solution {

public:

```
int recur(vector<int> &nums,int &S,int index,int sum)
{
if(index == nums.size())
{
if(sum == S)
return 1;
return 0;
}
int count = 0;
count += recur(nums,S,index+1,sum-nums[index]);
count += recur(nums,S,index+1,sum+nums[index]);
return count;
}
int findTargetSumWays(vector<int>& nums, int S) {
return recur(nums,S,0,0);
}
```

};