1726. Tuple with Same Product
Содержание
class Solution:
def tupleSameProduct(self, nums: List[int]) -> int:
cnt = defaultdict(int)
for i in range(1, len(nums)):
for j in range(i):
x = nums[i] * nums[j]
cnt[x] += 1
return sum(v * (v - 1) // 2 for v in cnt.values()) << 3