whats the mistake in my code… ??
i genereated all subsets and sum of that subset equal t…i printed it ?
whats the mistake in my code… ??
i genereated all subsets and sum of that subset equal t…i printed it ?
hello @hg11110000
u missed this case.
u r only sorting ur output.
but in question they have asked to print all rows in lexicographical order (ie first print row starting with least number , then rows starting with next smallest so on).
check output of this example for clarity->
.
but j is the index not the length so it should be till <= only
since on j’th idx also element is present
put all ur vectors(convert ur output array in vector) in set(set becuase by default it will arrange in lex order also it will keep only unique entries) and then print the set
sort ur input array as well
@aman212yadav
okay answer came but why to sort input array
we already did sort out each vector before inserting in a multiset
check ur code output for this case->
15
57 79 16 3 83 70 78 14 5 8 36 51 47 93 72
86
this is invalid output . u have included 5 twice
correct output ->
3 5 8 70
3 5 78
3 36 47
3 83
5 8 16 57
5 14 16 51
8 78
14 72
16 70
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.