Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Positive Negative Pair
EASY
10 mins
8 upvotes
Binary Search
Arrays
Topics (Covered in this problem)
Problem solved
Badge
Skill meter
Binary Search
-
-
Arrays
-
-
Other topics
Problem solved
Badge
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Positive Negative Pair

Contributed by
Vivek Kumar Mehta
Easy
yellow-spark
0/40
Avg time to solve 10 mins
Success Rate 90 %
Share
8 upvotes

Problem Statement

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

Note:
The pair consists of equal absolute values, one being positive and another negative.

Return an empty array, if no such pair exists.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1:
2
2
-2 2
2
1 2
Sample Output 1:
-2 2
Explanation For Sample Output 1:
Test case 1:
In the first test case, we can see that the absolute values of -2 and 2 are the same. But their signs are different(positive and negative). So that’s our answer. 

Test case 2:
There is no number present in the array with both positive and negative values. 
Sample Input 2:
2
6
1 -3 2 3 6 -1
8
4 8 9 -4 1 -1 -8 -9
Sample Output 2:
-1 1 -3 3
-1 1 -4 4 -8 8 -9 9
Reset Code
Full screen
Auto
copy-code
Console