Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
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)?
- A. 6
- B. 5
- C. 4
- D. 9
Correct answer: B. 5
Reduce each product modulo 7 first and then count distinct residues. Counting distinct products before reducing gives a different number.
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 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…
- What is the length of the longest contiguous subarray of [1, 2, 1, 3, 4, 3, 5] in which at most one element is a repeat of an earlier…
- How many trailing zeros does 50! (50 factorial) have in decimal?
- How many palindromic substrings of length at least 3 does "racecarxyzzyx" contain (counted by position)?
- For each value n in [10, 27, 50], count the positive integers x with x^3 <= n, then add the three counts. What is the total?