Hi can some one please go through the code.
Sum It up, getting all wrong answers
hey, simply sort the array and use the sliding window approach and you will reach the desired result, check and skip duplicates if they are the corner indices
I would like to know where am I wrong in this approach.
there is issue in the way u are backtracking
consider
8
1 2 3 4 4 4 5 3
7
it only prints
3 4
1 3 3
1 2 4
and not the case of 2 5
this is because once it reached 3 it did not backtrack to 2 again, for every combination found u must reset the values, plus the complexity of this solution is higher than the optimal one, you should look the optimal approach.
i hope i was able to solve your doubt. in case you want to try the recursive solution, use backtracking
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.