MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / helper

Method helper

Recursion/Code/subsetSum.cpp:15–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13class Solution{
14public:
15 bool helper (vector <int> a, int sum,int tempSum, int i){
16 //Base Cases
17 if (sum==tempSum){
18 return true;
19 }
20 if (sum<tempSum){
21 return false;
22 }
23 if (i>=a.size()){
24 return false;
25 }
26
27 //Recursive Calls
28 int recCall1 = helper(a,sum,tempSum+a[i],i+1);
29 int recCall2 = helper(a,sum,tempSum,i+1);
30
31 //Small Calculation
32 return recCall1 || recCall2;
33
34 }
35 bool isSubsetSum(vector<int>arr, int sum){
36 return helper(arr,sum,0,0);
37 // code here

Callers

nothing calls this directly

Calls 1

helperFunction · 0.70

Tested by

no test coverage detected