Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: How many ordered pairs (a, b) of positive integers satisfy a × b = 36 with a ≤ 100 and b ≤ 100?
- A. 5
- B. 7
- C. 8
- D. 9
Correct answer: D. 9
Each divisor a of 36 = 2² · 3² fixes b = 36 / a, and both stay ≤ 100, so the count is d(36) = 3 × 3 = 9. Counting unordered pairs gives 5, excluding 1 and 36 gives 7, and leaving out (6, 6) gives 8.
More Coding Interview Problems questions
- Problem: How many non-negative integer solutions (x, y, z) satisfy x + y + z = 10?
- Problem: How many integer solutions (x, y, z) with x, y, z ≥ 1 satisfy x + y + z = 10?
- Problem: A derangement is a permutation with no fixed point. How many derangements of 5 objects exist?
- Problem: How many binary trees (distinct shapes, ignoring labels) can be formed with 6 nodes?
- Problem: Count the integers from 1 to 64 whose binary representation has an even number of 1-bits.
- Problem: For the string "aaabbbbcc" with at most one replacement of any character by any other letter, what is the length of the longest…