You are given an integer array nums of length n and an integer array queries.
Consider all pairs of indices (i, j) such that nums[i] and nums[j]. Collect all of these values into an array gcdPairs and sort it in ascending order.
For each query queries[i], find the value located at index queries[i] in the sorted gcdPairs array.
Return an array of integers containing the answer to each query in queries.
Constraints:
nums.length
nums[i]
queries.length
queries[i]
You are given an integer array nums of length n and an integer array queries.
Consider all pairs of indices (i, j) such that nums[i] and nums[j]. Collect all of these values into an array gcdPairs and sort it in ascending order.
For each query queries[i], find the value located at index queries[i] in the sorted gcdPairs array.
Return an array of integers containing the answer to each query in queries.
Constraints:
nums.length
nums[i]
queries.length
queries[i]