description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
fin = 0
for i in range(len(nums1)):
res = 0
fin += self.finder(nums1[i], nums2, res)
for i in range(len(nums2)):
res = 0
fin += self.finder(nums2[i], nums1, res)... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR DICT... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
count = 0
dic1 = dict()
for num in nums1:
if num in dic1:
dic1[num] += 1
else:
dic1[num] = 1
dic2 = dict()
for num in nums2:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
lookup1 = dict()
lookup2 = dict()
for num1 in nums1:
lookup1[num1] = lookup1.get(num1, 0) + 1
for num2 in nums2:
lookup2[num2] = lookup2.get(num2, 0) + 1
mem = dict()
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FU... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1.sort()
nums2.sort()
n1 = collections.Counter([(num**2) for num in nums1])
cnt = 0
for i in range(1, len(nums2)):
for j in range(i):
if nums2[i] * nums2[j] in n... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
c1 = collections.Counter(nums1)
c2 = collections.Counter(nums2)
r = 0
for n in nums1:
for a in nums2:
t = n * n // a
if t * a == n * n:
i... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR NUMBER FO... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def helper(self, nums1, nums2):
n1 = len(nums1)
n2 = len(nums2)
ans = 0
h1 = {}
for j in range(n1):
for k in range(j + 1, n1):
if nums1[j] * nums1[k] not in h1:
h1[nums1[j] * nums1[k]] = 1
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
return self.num(nums1, nums2) + self.num(nums2, nums1)
def num(self, nums1, nums2):
possibleSquares = {}
possibleProducts = {}
for idx, x in enumerate(nums1):
square = x * x
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FU... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def wrapper(self, toSquare, toProd):
table = {}
for integer in toSquare:
squared = integer**2
if squared not in table:
table[squared] = 1
else:
table[squared] += 1
counter = 0
i = 0
while i <... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR NUM... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
dic1 = {}
dic2 = {}
for i in range(len(nums1) - 1):
for j in range(i + 1, len(nums1)):
v = nums1[i] * nums1[j]
if dic1.get(v) is None:
dic1[v] = ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
ret1 = self.check(nums1, nums2)
ret2 = self.check(nums2, nums1)
return ret1 + ret2
def check(self, n1: List[int], n2: List[int]):
count_n2_org = Counter(n2)
cnt = 0
for i in range(... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR VAR VAR FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR F... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def twoProduct(target, nums):
cnt = 0
currMap = collections.defaultdict(lambda: 0)
for num in nums:
if target % num == 0 and target // num in currMap:
c... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1, nums2):
mp1, mp2 = {}, {}
for ele in nums1:
if ele in mp1:
mp1[ele] += 1
else:
mp1[ele] = 1
for ele in nums2:
if ele in mp2:
mp2[ele] += 1
else:
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR DICT DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def getRoots(nums):
prods = []
for i, j in itertools.combinations(nums, 2):
prods.append(i * j)
return prods
def ways(nums1, nums2):
ans = 0
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR VAR RETURN VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
num1Map = defaultdict(int)
for i, n in enumerate(nums1):
num1Map[n] += 1
num2Map = defaultdict(int)
for i, n in enumerate(nums2):
num2Map[n] += 1
def count(nums, numsMa... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def count(arr, match):
n = len(arr)
cnt = 0
for i in range(n):
for j in range(i + 1, n):
val = math.sqrt(arr[i] * arr[j])
if match.g... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP FU... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
muti_set1 = set()
muti_set2 = set()
muti_dict1 = dict()
muti_dict2 = dict()
for i in range(len(nums1) - 1):
for j in range(i + 1, len(nums1)):
v = nums1[i] * nums1[j... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
n = len(nums1)
m = len(nums2)
nums2_pairs = Counter()
nums1_pairs = Counter()
for i in range(n):
for j in range(i + 1, n):
nums1_pairs[nums1[i] * nums1[j]] += 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def prod_finder(num_list1, num_list2):
prod_map = {}
for n in num_list1:
prod_map[n * n] = 0
for n in num_list1:
prod_map[n * n] += 1
count = 0
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1Counter, nums2Counter, result = Counter(nums1), Counter(nums2), 0
def isPerfectSquare(n):
squareRoot = math.sqrt(n)
return {
"status": squareRoot - floor(squareRoot) == 0,... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN DICT STRING STRING BIN_OP VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR STRING ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
self.ans = 0
def func(n1, n2):
for prod in n1:
i, j = 0, len(n2) - 1
while i < j:
if n2[i] == n2[j]:
if n2[i] * n2[j] != prod * ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FUNC_DEF FOR VAR VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR BIN_O... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
prod1 = {}
for i in range(len(nums1) - 1):
for j in range(i + 1, len(nums1)):
if nums1[i] * nums1[j] not in prod1.keys():
prod1[nums1[i] * nums1[j]] = 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1.sort()
nums2.sort()
def f(n):
if n == 2 or n == 1:
return 1
return f(n - 1) + n - 1
def yanzheng(a, num):
a = a * a
head = 0
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
map1 = {}
map2 = {}
for i in range(len(nums1)):
for j in range(i + 1, len(nums1)):
prod = nums1[i] * nums1[j]
map1.setdefault(prod, 0)
map1[prod] += ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUM... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def check(l1, l2):
res = {}
j = 0
while j < len(l2):
k = j + 1
while k < len(l2):
res[l2[j] * l2[k]] = res.get(l2[j] * l2[k], 0) + 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def twoProd(n1, n2):
d = Counter()
for i, a in enumerate(n1):
for j in range(i + 1, len(n1)):
d[a * n1[j]] += 1
return sum(d[i * i] for i in n2)
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def helper(nums1, nums2):
ret = 0
C = collections.Counter(nums2)
s = sorted(C)
for n in nums1:
ret += C[n] * (C[n] - 1) // 2
nn = n * n
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR IF VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN VAR RETURN BIN... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def helper(nums1: List[int], nums2: List[int]) -> int:
res = 0
counter = Counter(nums2)
for n1 in nums1:
sq = n1 * n1
for n2 in nums2:
i... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_C... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
c1, c2 = collections.Counter(nums1), collections.Counter(nums2)
res = 0
for n1 in nums1:
x = n1**2
for n2 in nums2:
if x % n2 == 0 and x // n2 in c2:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUM... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
cnt1_e = Counter()
cnt1_ne = Counter()
for i in range(len(nums1)):
cnt1_e[nums1[i] ** 2] += 1
for j in range(i + 1, len(nums1)):
cnt1_ne[nums1[i] * nums1[j]] += 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VA... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def generate_nums(nums):
nums = sorted(list(collections.Counter(nums).items()))
n = len(nums)
pow_nums = defaultdict(int)
mul_nums = defaultdict(int)
for i in range... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUM... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def cntProduct(square: int, nums: List[int]) -> int:
num_count, cnt = {}, 0
for num in nums:
if square % num == 0:
cnt += num_count.get(square // num, 0)
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF VAR VAR VAR ASSIGN VAR VAR DICT NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER RETURN VAR VAR RETURN BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR FUNC_... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1_cnt = collections.Counter(nums1)
nums1_square_cnt = {(x * x): nums1_cnt[x] for x in nums1_cnt}
nums2_cnt = collections.Counter(nums2)
nums2_square_cnt = {(y * y): nums2_cnt[y] for y in nums2_cnt}... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR VAR RETURN BIN_OP BIN_OP BI... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
Type1 = dict()
Product1 = dict()
Type2 = dict()
Product2 = dict()
for i in range(len(nums1)):
product = nums1[i] * nums1[i]
if product in Product1.keys():
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
n = len(nums1)
m = len(nums2)
res = 0
for x in nums1:
t = x * x
m = {}
for y in nums2:
if t % y == 0:
res += m.get(t // y, 0)
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR DICT FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR B... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTripletsHelper(self, nums1: List[int], nums2: List[int]) -> int:
nums1_map = {}
count = 0
for i in nums1:
if i in nums1_map:
nums1_map[i] += 1
else:
nums1_map[i] = 1
for i in nums2:
i_2 = i * ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR DICT FOR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def twoProduct(n, nums):
counter = collections.Counter()
res = 0
for num in nums:
if n % num == 0:
res += counter[n / num]
counter[num] ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR VAR |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
l1 = len(nums1)
l2 = len(nums2)
upper1 = []
upper2 = []
for i in range(l1):
for j in range(i + 1, l1):
upper1.append(nums1[i] * nums1[j])
for i in range(l2):... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CAL... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
d1 = {}
d2 = {}
for i in nums1:
if i in d1:
d1[i] += 1
else:
d1[i] = 1
for i in nums2:
if i in d2:
d2[i] += 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR VAR IF VAR VAR NUMBE... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | from itertools import combinations
class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
sq1, sq2 = [(num**2) for num in nums1], [(num**2) for num in nums2]
prod1, prod2 = [(combo[0] * combo[1]) for combo in combinations(nums1, 2)], [
(combo[0] * combo[1]) ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1.sort()
nums2.sort()
memo1 = collections.defaultdict(set)
memo2 = collections.defaultdict(set)
for i in range(len(nums1)):
memo1[nums1[i]].add(i)
for i in range(len(num... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CA... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def helper(l1, l2):
d = {}
for c in l1:
if c**2 in d:
d[c**2] += 1
else:
d[c**2] = 1
r = {}
for c in l2:... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
return self.triplets(nums1, nums2) + self.triplets(nums2, nums1)
def triplets(self, nums1, nums2):
nums1_sq = [(x * x) for x in nums1]
n_triplets = 0
for i in range(len(nums1_sq)):
num... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
return self.helper(nums1, nums2) + self.helper(nums2, nums1)
def helper(self, arr1, arr2):
res = 0
for num in arr1:
res += self.twoProduct(num * num, arr2)
return res
def twoProdu... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR IF VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
self.count = 0
def computeCount(nums1, nums2):
hashMap = {}
for i in range(len(nums1)):
checkNum = nums1[i] ** 2
for j in range(len(nums2)):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
res = 0
cnt1 = collections.Counter()
for j in range(len(nums2)):
for i in range(len(nums1)):
s = nums1[i] ** 2
if s % nums2[j] == 0 and s // nums2[j] in cnt1:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VA... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def helper(nums1, nums2):
res = 0
for num in nums1:
val = num**2
dic = collections.defaultdict(int)
for e in nums2:
res += dic[e]
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR NUMBER RETURN VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def count(n1, n2):
ret = 0
for x in n1:
seen = collections.defaultdict(int)
for y in n2:
if x * x % y == 0:
ret += seen[x * ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER RETURN VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
d1 = {}
d2 = {}
cnt1, cnt2 = 0, 0
for i in range(len(nums1)):
for j in range(i + 1, len(nums1)):
if nums1[i] * nums1[j] not in d1:
d1[nums1[i] * nums1[j]... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
if not nums1 or not nums2:
return 0
return self.helper(nums1, nums2) + self.helper(nums2, nums1)
def helper(self, nums1, nums2):
lookup = {}
count = 0
for num2 in nums2:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER VAR VAR VAR VAR VAR IF VAR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | from itertools import combinations
class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def isPerSq(n):
return int(math.sqrt(n) + 0.5) ** 2 == n
d1 = Counter(nums1)
d2 = Counter(nums2)
s = 0
for x, y in combinations(nums2, 2):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR VAR FUNC_CALL V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
res = 0
dic1 = {}
dic2 = {}
for i, e in enumerate(nums1):
target = e**2
for j in range(len(nums2)):
if target % nums2[j] == 0:
if nums2[j] in... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def twoProd(B, sq):
d = defaultdict(int)
cnt = 0
for val in B:
if sq % val == 0:
cnt += d.get(sq // val, 0)
d[val] += 1
retu... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
ans = 0
nums1.sort()
nums2.sort()
for i in range(len(nums2)):
ii = nums2[i] ** 2
ar = {}
for j in range(len(nums1)):
if ii % nums1[j] == 0:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def getRes(arr1, arr2):
count = 0
n = len(arr2)
max2 = arr2[-1]
for i in range(len(arr1)):
if arr1[i] > max2:
break
target =... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
A = collections.defaultdict(int)
B = collections.defaultdict(int)
ans = 0
for i in nums1:
a = i * i
B.clear()
for j in nums2:
b = j * j
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def findTriplet2(arr1, arr2):
result = 0
m = len(arr2)
count = collections.Counter([(x**2) for x in arr1])
for j in range(m):
for k in range(j + 1, m):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR FUNC_DEF ASS... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
ans = 0
n1 = defaultdict(int)
for n in nums1:
n1[n] += 1
n2 = defaultdict(int)
for n in nums2:
n2[n] += 1
for j in range(len(nums1)):
for k in range(... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMB... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
result = 0
for i in range(len(nums1)):
dic = collections.defaultdict(int)
for j in range(len(nums2)):
target = nums1[i] ** 2 / nums2[j]
if target in dic:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
ans = 0
for n in nums1:
n2 = n * n
seen = collections.defaultdict(int)
for i in range(len(nums2)):
ans += seen[n2 / nums2[i]]
seen[nums2[i]] += 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1.sort()
nums2.sort()
count = self.counttrip(nums1, nums2)
count += self.counttrip(nums2, nums1)
return int(count)
def counttrip(self, nums1, nums2):
seen = defaultdict(int)
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
memo1, memo2 = collections.Counter(), collections.Counter()
for a, b in itertools.combinations(nums1, 2):
temp = int(math.sqrt(a * b))
if temp**2 == a * b:
memo1[temp] += 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
n = len(nums1)
m = len(nums2)
n2dict = defaultdict(int)
m2dict = defaultdict(int)
for x in nums1:
n2dict[x * x] += 1
for x in nums2:
m2dict[x * x] += 1
o... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR BIN_OP VAR VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIG... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def find(self, n1, n2, c1):
res = 0
for j in range(len(n2)):
for k in range(j + 1, len(n2)):
t = n2[j] * n2[k]
sqrt = t**0.5
if sqrt**2 != t:
continue
try:
i = c1[sqrt... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER VAR VAR RETURN VAR FUNC_DEF VAR VAR VAR VAR ASSIGN VAR N... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def twoProduct(list1, list2, target):
res = 0
counter = collections.defaultdict(int)
for j in range(len(list2)):
q, r = divmod(target, list2[j])
if r == 0 a... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER FOR VAR VA... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1 = list(Counter(nums1).items())
nums2 = list(Counter(nums2).items())
def find(target, count1, arr):
seen = Counter()
ans = 0
for a, count2 in arr:
if t... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR FUNC_CALL V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
d1, d2 = dict(), dict()
for idx, n1 in enumerate(nums1):
d1[idx] = dict()
for elm in nums1[idx + 1 :]:
try:
d1[idx][elm] += 1
except KeyError... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FOR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FOR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUM... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
set1 = Counter(nums1)
set2 = Counter(nums2)
N1 = len(nums1)
N2 = len(nums2)
n1sq = [(n * n) for n in nums1]
n2sq = [(n * n) for n in nums2]
ntr = 0
for i1 in range(N1):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBE... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
m1 = collections.defaultdict(lambda: 0)
m2 = collections.defaultdict(lambda: 0)
for i in range(len(nums1)):
m1[nums1[i] ** 2] += 1
for i in range(len(nums2)):
m2[nums2[i] ** 2] ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def countTriplets(nums1, nums2):
count = 0
for index, val in enumerate(nums1):
target = int(val**2)
lookup = defaultdict(int)
for index2, val2 in enumer... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def twoProduct(target, nums) -> int:
goal = defaultdict(list)
tot = 0
for i in range(len(nums)):
if len(goal[nums[i]]) != 0:
tot += len(goal[nums[i]])
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1.sort()
nums2.sort()
def numValid(target, nums):
start, end = 0, len(nums) - 1
ans = 0
while start < end:
if target * target == nums[start] * nums[end]... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR N... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
count = 0
for x in nums1:
seen = {}
v = x * x
for i in nums2:
if i in seen:
count += seen[i]
seen[v / i] = seen.get(v / i, 0) + 1... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR BI... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
ct = 0
d = {}
for j in range(len(nums2)):
for k in range(j + 1, len(nums2)):
if nums2[j] * nums2[k] in d:
d[nums2[j] * nums2[k]] = d[nums2[j] * nums2[k]] + 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, a1: List[int], a2: List[int]) -> int:
ans, m1, m2, n1, n2 = (
0,
Counter([(x**2) for x in a1]),
Counter([(x**2) for x in a2]),
len(a1),
len(a2),
)
for i in range(n1 - 1):
for j in r... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VA... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
d1 = collections.Counter(nums1)
d2 = collections.Counter(nums2)
ans = 0
for i in range(len(nums1)):
for j in range(i + 1, len(nums1)):
p = nums1[i] * nums1[j]
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
ans = 0
def helper(l1, l2):
nonlocal ans
c = Counter(l2)
for x in l1:
num = x * x
c2 = c.copy()
for i in range(len(l2)):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VA... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
ret = 0
dict1 = defaultdict(int)
dict2 = defaultdict(int)
for j in range(len(nums2)):
for k in range(j + 1, len(nums2)):
dict2[nums2[j] * nums2[k]] += 1
for j in ran... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def cnt(tot, arr):
mp = {}
ans = 0
for val in arr:
if tot % val == 0 and tot / val in mp:
ans += mp[tot / val]
mp[val] = mp.get(val, 0) ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR VAR VAR FUNC_CALL VAR B... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
res = 0
res += sum(self.get_target_products(n * n, nums2) for n in nums1)
res += sum(self.get_target_products(n * n, nums1) for n in nums2)
return res
def get_target_products(self, target, nums):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
p1 = {}
p2 = {}
c = 0
for i in range(len(nums1)):
for j in range(len(nums1)):
if i != j:
p1[nums1[i] * nums1[j]] = p1.get(nums1[i] * nums1[j], 0) + 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | def func(xs, ys):
sqs = [(x**2) for x in xs]
seen = collections.defaultdict(int)
res = 0
for y in ys:
for x in sqs:
if x % y == 0:
res += seen[x // y]
seen[y] += 1
return res
class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) ... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR CLASS_DEF FUNC_DEF VAR VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
count1 = collections.Counter(nums1)
count2 = collections.Counter(nums2)
def cal(nums1, count2):
ans = 0
for n1 in nums1:
sq = n1**2
for n2 in sorted(cou... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR IF VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
m = len(nums1)
n = len(nums2)
pairs1 = []
pairs2 = []
for i in range(n):
for j in range(i + 1, n):
pairs2.append(nums2[i] * nums2[j])
for i in range(m):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CAL... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
set1 = collections.defaultdict(set)
for i, num in enumerate(nums1):
set1[num].add(i)
set2 = collections.defaultdict(set)
for i, num in enumerate(nums2):
set2[num].add(i)
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER F... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
c1 = collections.Counter([(i * i) for i in nums1])
c2 = collections.Counter([(i * i) for i in nums2])
res = 0
for i in range(len(nums1)):
for j in range(i + 1, len(nums1)):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FO... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
m1_square, m2_square = {}, {}
for x in nums1:
x_square = x**2
m1_square[x_square] = m1_square.get(x_square, 0) + 1
for x in nums2:
x_square = x**2
m2_square[x_sq... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR VAR DICT DICT FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER F... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def count(A, B):
res = 0
n1 = len(A)
n2 = len(B)
for i in range(n1):
target = A[i] ** 2
d = collections.defaultdict(int)
for num... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR RETURN BIN_OP FUNC_CALL VAR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
prod2 = collections.defaultdict(int)
for i in range(len(nums2)):
for j in range(i + 1, len(nums2)):
prod = nums2[i] * nums2[j]
if prod in prod2:
prod2[pr... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NU... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
dic1 = {}
dic2 = {}
s1 = []
s2 = []
r = 0
n1 = len(nums1)
n2 = len(nums2)
for i in range(n1):
r += self.helper(nums1[i] * nums1[i], nums2)
for i in r... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RET... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
d1 = defaultdict(list)
d2 = defaultdict(list)
for i, x in enumerate(nums1):
for j, y in enumerate(nums1):
if j <= i:
continue
r = int(sqrt(x * y)... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR FUNC_CALL VAR VAR FOR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def typeone(n1, n2):
L1 = len(n1)
L2 = len(n2)
dic = {}
count = 0
for j in range(L2 - 1):
for k in range(j + 1, L2):
if n2[j] * ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR NU... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, A: List[int], B: List[int]) -> int:
def getTriplets(A, B):
m, n = len(A), len(B)
ans = 0
counter = Counter()
for j in range(n):
for k in range(j + 1, n):
prod = B[j] * B[k]
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1_squared = [(i**2) for i in nums1]
nums2_squared = [(i**2) for i in nums2]
c1 = collections.Counter(nums1)
c2 = collections.Counter(nums2)
res = 0
for n1 in nums1:
for ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def wrapper(self, toSquare, toProd):
table = {}
for integer in toSquare:
squared = integer**2
if squared not in table:
table[squared] = 1
else:
table[squared] += 1
counter = 0
i = 0
while i <... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR NUM... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
count = self.findTriple(nums1, nums2)
count += self.findTriple(nums2, nums1)
return count
def findTriple(self, nums1, nums2):
counts = {}
for num in nums2:
if num not in counts... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
nums1.sort()
nums2.sort()
def cnt(tot, arr):
mp = {}
ans = 0
for val in arr:
if tot % val == 0 and tot / val in mp:
ans += mp[tot / val]... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NUMBER F... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
rep = 0
rep += self.getNumTriplets(nums1, nums2)
rep += self.getNumTriplets(nums2, nums1)
return rep
def getNumTriplets(self, nums1, nums2):
num1 = [(n**2) for n in nums1]
num2 = [... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP ... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
res = 0
s1 = collections.Counter()
for n1 in nums1:
s2 = collections.Counter()
for n2 in nums2:
if n1 * n1 % n2 == 0 and n1 * n1 // n2 in s2:
res += ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR V... |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def check(A, B):
n, res = len(B), 0
C = Counter(map(lambda i: i * i, A))
for i in range(n):
for j in range(i + 1, n):
res += C[B[i] * B[j]]
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where ... | class Solution:
def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
def helper(target, nums):
ret = 0
target = target * target
d = {}
s = set()
for n in nums:
if n in d:
s.add((min(n, target // n)... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.