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

Method helper

Recursion/Homework/subsetSum.cpp:12–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10class Solution{
11public:
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

Callers

nothing calls this directly

Calls 1

helperFunction · 0.70

Tested by

no test coverage detected