| 8 | //User function template for C++ |
| 9 | |
| 10 | class Solution{ |
| 11 | public: |
| 12 | bool helper (vector <int> a, int sum,int tempSum, int i){ |
| 13 | //Base Cases |
| 14 | if (sum==tempSum){ |
| 15 | return true; |
| 16 | } |
| 17 | if (i>=a.size()){ |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | //Recursive Calls |
| 22 | int recCall1 = helper(a,sum,tempSum+a[i],i+1); |
| 23 | int recCall2 = helper(a,sum,tempSum,i+1); |
| 24 | |
| 25 | //Small Calculation |
| 26 | return recCall1 || recCall2; |
| 27 | |
| 28 | } |
| 29 | bool isSubsetSum(vector<int>arr, int sum){ |
| 30 | return helper(arr,sum,0,0); |
| 31 | // code here |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | // { Driver Code Starts. |
| 36 | int main() |
nothing calls this directly
no outgoing calls
no test coverage detected