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

Method helper

Recursion/Homework/Subsets.cpp:19–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 //vector is a Dynamic Data structure similar to array but unlike array we do not need to declare its size in advance
18
19 void helper(vector <int> A,vector<int>temp, int i){
20 if (i==A.size()){ //Base Case
21 ans.push_back(temp); //this will keep the contents of temp in ans for now
22 return;
23 }
24
25 temp.push_back(A[i]); //Appends or adds element at the end
26 helper(A,temp,i+1); //Inclusion or Take condition
27
28 temp.pop_back(); //Removes an element from the end
29 helper(A,temp,i+1); //Exclusion or not-take condition
30
31 return;
32 }
33
34 vector<vector<int> > subsets(vector<int>& A)
35 {

Callers

nothing calls this directly

Calls 1

helperFunction · 0.70

Tested by

no test coverage detected