Given an array `nums` of **distinct** positive integers, return the number of tuples `(a, b, c, d)` such that `a * b = c * d`, where `a`, `b`, `c` and `d` are elements of `nums` and `a != b != c != d` (all four are different elements).
Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d, where a, b, c and d are elements of nums and a != b != c != d (all four are different elements).
Example 1:
Input: {"nums":[2,3,4,6]}
Output: 8
Constraints:
1≤nums.length≤1000
1≤nums[i]≤104
All elements in nums are distinct.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[2,3,4,6]}
Every pair (a, b) has a product. Two pairs with the same product make 8 tuples, so group the 6 pairs by product.