Sum it up problem


what is the error in my code not getting correct vresult

HI, I am trying to debug it wait for a while

This is a simple question of recursion and backtracking
just insert the present element into temporary vector .incremenet the pointer to next position & add the present array value to sum
also since duplicate values are present we check for the condition
if( j > i and arr[j] == arr[j-1] ) we do no include that combination again
this removes duplicay of combination maaking a target sum

Thanks mam… Can you explain the conceptual mistake in my code

mam when i am changing for each loop in the form
for(int j=0;j<v.size();j++)
{
cout<<v[i]<<" ";
}
the anser is not coming why??

use v[j] & not v[i] in the code u are using

and can you tell me the mistake in my code so can i do not do it again??

ya wait for a minute let me analyse the code

see
there are various udpates
logically not a lot of changes
just a additional feature that duplicate elements are not inserted is added on line 33
prohibit from using array as the array name … use some other name like arr.

i have added comments to ur code

Did u get ur mistake now
?
I hope i was of some help to u

1 Like

yes mam now i got it thanks …

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.