You are given an integer array nums.
A pair of indices (i, j) is called balanced perfect if the following conditions hold:
1. i < j
2. Let a = nums[i] and b = nums[j]. Then:
o min(|a - b|, |a + b|) <= min(|a|, |b|)
o max(|a - b|, |a + b|) >= max(|a|, |b|)
Your task is to count how many distinct balanced perfect pairs exist in the array.
Note:
The absolute value |x| refers to the non-negative value of x.
Input: nums = [-2, 4, -3, 6]
Output: 3
Input: nums = [1, 3, 5, 7]
Output: 5
Accepted:
Submission: