One test case not passing. Please help me debug…
Arrays - target sum triplets
Your code is not visible to me, please share your code so that I can help
collaborate mode is on…
I checked there, but your code is not visible to me
should be visible now…
No, it is not. It is showing me a blank ide, maybe there is some issue from the backend. Instead, you could just share your code using ide.codingblocks.com and I’ll help you out then
-
Note that in this question, the answers are sorted twice/in two ways - a) All the different possible triplets are sorted and b) All elements of a particular triplet are sorted among themselves.
You need to ensure that both these are covered by your code. You are able to correctly print the order of each triplet, but all the answers are not sorted among themselves. For doing that, all you need to do, is pass a sorted array to your function. That is, after taking input of your array, apply Arrays.sort(arr) and then pass this sorted array to your function. This will automatically ensure that all your answers are sorted among themselves. -
Check you for loops. If j starts from i+1, then the condition on i should not be i<arr.length, you will only go till arr.length-3, similarly k starts from j+1, so check condition for j. Otherwise you will get out of bound error.
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.