Class Solution
java.lang.Object
g1701_1800.s1726_tuple_with_same_product.Solution
1726 - Tuple with Same Product.<p>Medium</p>
<p>Given an array <code>nums</code> of <strong>distinct</strong> positive integers, return <em>the number of tuples</em> <code>(a, b, c, d)</code> <em>such that</em> <code>a * b = c * d</code> <em>where</em> <code>a</code><em>,</em> <code>b</code><em>,</em> <code>c</code><em>, and</em> <code>d</code> <em>are elements of</em> <code>nums</code><em>, and</em> <code>a != b != c != d</code><em>.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [2,3,4,6]</p>
<p><strong>Output:</strong> 8</p>
<p><strong>Explanation:</strong> There are 8 valid tuples:</p>
<p>(2,6,3,4) , (2,6,4,3) , (6,2,3,4) , (6,2,4,3)</p>
<p>(3,4,2,6) , (4,3,2,6) , (3,4,6,2) , (4,3,6,2)</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [1,2,4,5,10]</p>
<p><strong>Output:</strong> 16</p>
<p><strong>Explanation:</strong> There are 16 valid tuples:</p>
<p>(1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)</p>
<p>(2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)</p>
<p>(2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4)</p>
<p>(4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 1000</code></li>
<li><code>1 <= nums[i] <= 10<sup>4</sup></code></li>
<li>All elements in <code>nums</code> are <strong>distinct</strong>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
tupleSameProduct
public int tupleSameProduct(int[] nums)
-