Data Structures & AlgorithmsHardGATE CS · TCS NQT
How many unordered pairs {x, y} of distinct integers from 1 to 20 have x + y divisible by 5?
- A. 76
- B. 38
- C. 48
- D. 32
Correct answer: B. 38
Residues mod 5 have four numbers each; valid pairs are (0,0): C(4,2) = 6, (1,4): 16 and (2,3): 16, total 38. Counting ordered pairs gives 76, using 4 × 4 for the (0,0) class gives 48, and forgetting that class gives 32.
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
- For "dcbadcba", among its rotations, which starting index i (0-based, the rotation s[i:] + s[:i]) gives the lexicographically smallest…
- What is the maximum nesting depth of parentheses in "(()(()))()"?
- How many distinct values does floor(n / 3) take as n ranges over 1 to 20 inclusive?
- What is the sum of an = n mod 7 for n from 1 to 20 inclusive?
- From [1, 2, 2, 3, 5, 6, 6], what is the maximum number of disjoint pairs where the two values differ by at most 1?
- How many integers from 1 to 64 inclusive have a binary representation (without leading zeros) that reads the same forwards and backwards?