Problem · Array
Find All Pairs of Integers
Learn this problemProblem statement
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|)
Function
findAllPairs(arr: int[]) → int[][]Examples
Example 1
arr = [2, 5, -3]return = [[2, -3], [5, -3]]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
🍅🍅More Salesforce problems
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Final Pod Counts After LogsOA · Seen May 2026
- ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
- Generate Seen Binary StringsOA · Seen May 2026
- Update Pod Counts From LogsOA · Seen May 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026