Please provide me with some reference for this question which I could use to solve this question.
Hints required for solution
this is the approach :
- Sort the array(non-decreasing).
- First remove all the duplicates from array.
- Then use recursion and backtracking to solve the problem.
-
- If at any time sub-problem sum == 0 then add that array to the result (vector of vectors).
-
- Else if sum if negative then ignore that sub-problem.
-
- Else insert the present array in that index to the current vector and call the function with sum = sum-ar[index] and index = index, then pop that element from current index (backtrack) and call the function with sum = sum and index = index+1
-
if we would remove the duplicate index then how would we pass the test case :
because in the given test case one possible answer is 1 1 6 which is only possible if there are two 1 and if we would delete one of the 1 then how would be able to get this answer
see this, you can debug this