Data Structures & AlgorithmsModerateTCS NQT · SSC CGL Tier 2
Problem: What is the least common multiple of 6, 8 and 12?
- A. 576
- B. 24
- C. 48
- D. 2
Correct answer: B. 24
Highest prime powers: 2³ from 8 and 3 from 6 or 12, so lcm = 24. The product 6 · 8 · 12 = 576 overcounts, 6 · 8 = 48 multiplies just two of them, and 2 is the gcd.
More Coding Interview Problems questions
- Problem: How many trailing zeros does 30! have in base 10?
- Problem: How many unordered pairs {x, y} with x ≠ y from the set {1, 2, 3, 4, 5} have x + y even?
- Problem: How many binary strings of length 4 contain no two adjacent 1s?
- Problem: How many two-digit numbers (10–99) have digits that sum to exactly 9?
- Problem: The undirected graph on vertices 0, 1, 2 has edges 0-1 (5), 1-2 (5) and 0-2 (12). What is the shortest path length from 0 to 2?
- Problem: A complete binary tree has all levels full with depths 0 to 4 (root at depth 0). How many nodes does it have in total?