FastPrepFastPrep
Problem Brief

Find Number of Perfect Pairs

OA

A perfect pair (x, y) is such that min( | x - y |, | x + y | ) <= min( | x |, | y |) and max( | x - y |, | x + y | ) >= max( | x |, | y |). Given an array of unsorted integers, find the number of perfect pairs.

Function Description

Complete the function findNumberOfPerfectPairs in the editor.

findNumberOfPerfectPairs has the following parameter:

  1. int[] nums: an array of integers

Returns

int: the number of perfect pairs

1Example 1

Input
nums = [2, -3, 5]
Output
2
Explanation
(2, -3) and (-3, 5) are perfect pairs
public int findNumberOfPerfectPairs(int[] nums) {
  // write your code here
}
Input

nums

[2, -3, 5]

Output

2

Sign in to submit your solution.