Arrays - Target sum Pair

Question :
To print out all the pairs in ascending order from the array which would produce the given sum.
how do I figure out why the test case is failing? I couldn’t figure out the error/bug in my algorithm.

here is my code :

hi @aryangoel971_1b263dfa601b9409
i have corrected ur code… it should work fine now…

where was the error in algorithm ?

and what was the error can you elaborate that ?

hi @aryangoel971_1b263dfa601b9409
either u do a brute force way, or if u use 2 pointer method then u will have to keep one pointer at starting and other at end…

hi @aryangoel971_1b263dfa601b9409
i hope its clear now??

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.