Tap here to switch tabs
Problem
Submissions

Problem: Tuple with Same Product

med
30 min
Try to solve the Tuple with Same Product problem.

Statement

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:

  1. a, b, c, and d are all taken from nums

  2. a * b equals c * d

  3. 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 nums can be used at most once within a single tuple because all four values must come from distinct indices.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤104\leq 10^4

  • All elements in nums are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Tuple with Same Product

med
30 min
Try to solve the Tuple with Same Product problem.

Statement

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:

  1. a, b, c, and d are all taken from nums

  2. a * b equals c * d

  3. 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 nums can be used at most once within a single tuple because all four values must come from distinct indices.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤104\leq 10^4

  • All elements in nums are distinct.