Data Structures & AlgorithmsHardTCS NQT Digital · CAT
Problem: In the array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], find the number of pairs (i, j) with i < j whose product is a multiple of 12.
- A. 8
- B. 16
- C. 9
- D. 6
Correct answer: A. 8
Pairs with 12 | x·y among 1..10 (e.g. (2,6), (3,4), (3,8), (4,6), (6,8), (6,10), (4,9), (8,9)) number 8. Ordered pairs give 16, allowing x = y adds (6,6) for 9, and requiring one factor to hold all of 4 and the other all of 3 gives 6.
More Coding Interview Problems questions
- Problem: How many 5-digit numbers (10000–99999) have digits that sum to exactly 6 and begin with the digit 1?
- Problem: A string of 6 characters is formed from the letters {a, b} such that no two adjacent characters are equal. How many such strings…
- Problem: The Euclidean distance squared between (1,2) and (4,6) is what integer?
- Problem: In the sequence 2, 3, 5, 8, 12, 17, … each term increases by one more than the previous increase (differences 1, 2, 3, 4, …)…
- Problem: How many 4-element subsets of {1, 2, ..., 8} have a sum that is a multiple of 5?
- Problem: The array [4, 9, 16, 25] has its square roots summed. What is the sum of the square roots of these four numbers?