Given an integer array nums with all distinct values, count the number of tuples (a, b, c, d) such that a * b == c * d, where a, b, c, and d are values chosen from nums.
A tuple (a, b, c, d) is considered valid when:
a, b, c, and d are all taken from nums
a * b equals c * d
The order of elements in the tuple matters, so different permutations count as different tuples
Return the total number of valid tuples.
Note: Each element of
numscan be used at most once within a single tuple because all four values must come from distinct indices.
Constraints:
nums.length
nums[i]
All elements in nums are distinct.
Given an integer array nums with all distinct values, count the number of tuples (a, b, c, d) such that a * b == c * d, where a, b, c, and d are values chosen from nums.
A tuple (a, b, c, d) is considered valid when:
a, b, c, and d are all taken from nums
a * b equals c * d
The order of elements in the tuple matters, so different permutations count as different tuples
Return the total number of valid tuples.
Note: Each element of
numscan be used at most once within a single tuple because all four values must come from distinct indices.
Constraints:
nums.length
nums[i]
All elements in nums are distinct.