Data Structures & AlgorithmsModerateTCS NQT · ICPC regional
Problem: From the list [12, 18, 24, 30, 36], what is the number of distinct prime divisors of the product of all five numbers?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
All five numbers factor into 2, 3 and 5 only, so the product has three distinct prime divisors. Counting prime factors with multiplicity gives a much larger number.
More Coding Interview Problems questions
- Problem: The array [7, 1, 5, 3, 6, 4] is processed to find the maximum profit from one buy and one later sell (0 if none). What is the…
- Problem: A grid of 3×3 cells is numbered 1 to 9 row by row. Starting at 1 (top-left), the robot moves right or down. The number of paths…
- Problem: A list of intervals is [1,5], [2,3], [4,8], [7,9], [10,11]. Merge all overlapping intervals (touching at an endpoint counts as…
- Problem: The string "aabbbcccc" is encoded by writing each letter followed by its count, e.g. "a2b3c4". What is the length of the encoded…
- Problem: What is the number of inversions in the array [2, 5, 1, 4, 3]?
- Problem: The array [3, 7, 1, 9] is used to create all non-empty contiguous subarrays. How many of them have an odd sum?