Problem Brief
Find All Pairs of Integers
FULLTIMEOA
See Salesforce online assessment and hiring insights
Given array of integers, find all pairs of integers (x,y) from the array that satisfy below conditions:
- min(|x - y|, |x + y|) <= min(|x|, |y|)
- max(|x - y|, |x + y|) >= max(|x|, |y|)
1Example 1
Input
arr = [2, 5, -3]
Output
[[2, -3], [5, -3]]
Explanation
An educated guess -
The pairs that satisfy the given conditions are:
(2, -3): min(|2 - (-3)|, |2 + (-3)|) = min(5, 1) = 1 <= min(2, 3) = 2 and max(5, 1) = 5 >= max(2, 3) = 3
(5, -3): min(|5 - (-3)|, |5 + (-3)|) = min(8, 2) = 2 <= min(5, 3) = 3 and max(8, 2) = 8 >= max(5, 3) = 5
Constraints
Limits and guarantees your solution can rely on.
๐
๐