Pairs with Positive Negative values
Easy Accuracy: 31.06% Submissions: 1149 Points: 2

Given an array of distinct integers, print all the pairs having positive value and negative value of a number that exists in the array.

NOTE: If there is no such pair in the array , return empty array.

Example 1:

n = 6
a[] = {1, -3, 2, 3, 6, -1}
-1 1 -3 3 


Example 2:

n = 8
a[] = {4, 8, 9, -4, 1, -1, -8, -9}
-1 1 -4 4 -8 8 -9 9

Your Task:  
You don't need to read input or print anything. Your task is to complete the function PosNegPair() which takes the array a[] and its size n as inputs and returns all the required pairs in the increasing order of their absolute numbers.


Expected Time Complexity: O(nLog(n))
Expected Auxiliary Space: O(n)



We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Pairs with Positive Negative values

Output Window