Tap here to switch tabs
Problem
Submissions

Problem: Ways Where Square of a Number Equals Product of Two

Ways Where Square of a Number Equals Product of Two asks you to count triplets across two integer arrays where one value squared equals the product of two distinct values in either direction.

Statement

Given two arrays of integers nums1 and nums2, return the total number of valid triplets formed under the following conditions:

Type 11: A triplet (i, j, k) where 0≤0 \leq i << nums1.length and 0≤0 \leq j << k << nums2.length, such that nums1[i]2==^2 == nums2[j] $ imes$ nums2[k].

Type 22: A triplet (i, j, k) where 0≤0 \leq i << nums2.length and 0≤0 \leq j << k << nums1.length, such that nums2[i]2==^2 == nums1[j] $ imes$ nums1[k].

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤1000\leq 1000

  • 1≤1 \leq nums1[i], nums2[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Ways Where Square of a Number Equals Product of Two

Ways Where Square of a Number Equals Product of Two asks you to count triplets across two integer arrays where one value squared equals the product of two distinct values in either direction.

Statement

Given two arrays of integers nums1 and nums2, return the total number of valid triplets formed under the following conditions:

Type 11: A triplet (i, j, k) where 0≤0 \leq i << nums1.length and 0≤0 \leq j << k << nums2.length, such that nums1[i]2==^2 == nums2[j] $ imes$ nums2[k].

Type 22: A triplet (i, j, k) where 0≤0 \leq i << nums2.length and 0≤0 \leq j << k << nums1.length, such that nums2[i]2==^2 == nums1[j] $ imes$ nums1[k].

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤1000\leq 1000

  • 1≤1 \leq nums1[i], nums2[i] ≤105\leq 10^5