You are given an integer array
nums
of lengthn
and an integer arrayqueries
.Let
gcdPairs
denote an array obtained by calculating the GCD of all possible pairs(nums[i], nums[j])
, where0 <= i < j < n
, and then sorting these values in ascending order.For each query
queries[i]
, you need to find the element at indexqueries[i]
ingcdPairs
.Return an integer array
answer
, whereanswer[i]
is the value atgcdPairs[queries[i]]
for each query.The term
gcd(a, b)
denotes the greatest common divisor ofa
andb
.