#3312

Sorted GCD Pair Queries

international master · 2160 · lc hard +32 · premium · 22.4% accepted · 100 likes · top 2%

Description

You are given integer array nums of length n and integer array queries. Let gcdPairs be the sorted array of GCDs of all pairs (nums[i], nums[j]) with i < j. For each queries[i], return the element at index queries[i] in gcdPairs.

Code

1
2
3