Data Structures & AlgorithmsHardGATE CS · TCS NQT
What is the sum of gcd(a, b) over all unordered pairs of distinct elements of [6, 10, 15]?
- A. 11
- B. 10
- C. 30
- D. 8
Correct answer: B. 10
The three pairs have gcd 2, 3 and 5, which total 10. Taking the product of each pair instead of the gcd is the usual slip.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many contiguous subarrays of [2, 4, 2, 1, 3] have a sum exactly equal to twice their maximum?
- With coins of denominations 1, 5, 6 and 9, what is the minimum number of coins needed to make the amount 15?
- Including the empty prefix (sum 0), how many of the prefix sums of [3, 1, 4, 2, 6, 5, 3, 1] are divisible by 4?
- How many distinct residues modulo 7 are produced by x y for x and y ranging over {2, 3, 4} (all ordered pairs, including x = y)?
- How many pairs i < j in [4, 1, 5, 2, 3] satisfy a[i] > a[j] and every element strictly between them is at most a[i]?
- How many ordered pairs (i, j) with i != j in [1, 3, 2, 6, 4] have a[i] AND a[j] = a[i], meaning the bits of a[i] are a subset of the bits…