code fails 1 and 4 test case
https://ide.codingblocks.com/s/60448
Target sum pairs;
For target sum pair , you have to use sliding window approach .
Sort the given array and take two pointers , 1 at the starting of array and other at the end.
This will reduce the complexity of code and pass all the testcase.
is there any other way
other than using sliding window approach
Brute force approach (Two loops) which you did . But , you have to submit your answer in given constraints . The compiler can solve near about 10^8-10^9 iterations in 1 sec. This approach will take more iterations as its complexity is O(n^2) .
Hey Pratik,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.