Data Structures & AlgorithmsVery hardCodeforces Div2 C · TCS NQT
How many unordered pairs of distinct positions in [2, 3, 4, 6, 8, 9, 12] have a product divisible by 6?
- A. 17
- B. 1
- C. 18
- D. 15
Correct answer: A. 17
Divisibility of a product depends on the combined prime factors, not on each factor separately: 2 and 3 together make 6 even though neither alone is divisible by 6. Requiring each factor to be divisible by k misses these pairs.
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 DISTINCT substrings of length exactly 3 does "abcabcbb" contain?
- How many substrings of "aeixoaeiuxoaeiou" consist only of vowels AND contain all five vowels a, e, i, o, u at least once?
- Consider the pattern-matching algorithms: naive, KMP, Rabin–Karp (polynomial rolling hash), Z-function. Which statement is correct?
- A polynomial rolling hash with a fixed modulus M and random base B is used to compare two different strings of length L. Which statement…
- What is the length of the longest palindromic substring of "bananaracecarbnn"?
- Apply the reversal of the first 4 elements to the queue 1, 2, 3, 4, 5, 6, 7, 8 (front first). What is the element at position 6 of the…