Sum it up (backtracking)

hey i am getting run time error in my code. Kindly help.

https://ide.codingblocks.com/s/67160

@Tanay-Burreja-479544972538432 hey tanay why are you using loop in line 11. I am discussing new approach with you implement using it with set or vector and
if(s==0){
vector temp;
int k;
for(k=0;k<j;k++)
temp.push_back(out[k]);
ans.insert(temp);
return;
}
here ans is set<vector >ans;
make two call 1 in which you have to subtract input from s
and in call 2 simple pass s with other entity.
if any queries comes feel free to ask

1 Like

@jaiskid what i am trying to do is marking the indexes of elements(in out[]) that give the target sum.
and using for loop i am printing the elements. Is anything wrong in my approach ?
please help me debug the code and i didn’t properly understand your approach.

@Tanay-Burreja-479544972538432 check your loop it has no effect on your code.

Hey Tanay,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.