Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B
What is the greatest common divisor of 6, 24, 60, 120 and 210?
- A. 7
- B. 8
- C. 6
- D. 10
Correct answer: C. 6
The common factors of all five numbers are the divisors of 6, and 6 divides each of them. Taking the gcd pairwise and folding gives the same value.
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 trailing zeros does 50! have when written in base 12 (note 12 = 2^2 3)?
- How many integers x in [1, 1000] satisfy x ≡ 2 (mod 13) and x ≡ 5 (mod 17)?
- How many index pairs i < j in [1, 2, ..., 10] (the integers 1 to 10) have i j divisible by 4?
- Start with the stack [1]. Operations in order: DUP (push a copy of the top), ADD (pop two and push their sum), DUP, DUP, ADD, ADD. What is…
- Two queues hold [1, 3, 5] and [2, 4, 6]. The output takes one element from the first queue, then one from the second, alternately, until…
- Which technique gives O(1) time per query for 'sum of a[l..r]' on a static array after O(n) preprocessing?