Data Structures & AlgorithmsModerateTCS NQT · CAT
Problem: A rectangle of 12 by 18 units is cut into the largest possible identical squares that tile it exactly. How many such squares are used?
- A. 24
- B. 216
- C. 6
- D. 36
Correct answer: C. 6
The side is gcd(12, 18) = 6, giving (12/6) · (18/6) = 2 · 3 = 6 squares. Side 3 gives 24 squares, side 1 gives 216, and 36 is the lcm, not a count.
More Coding Interview Problems questions
- Problem: The number 720 is written as a product of primes. What is the sum of its distinct prime factors?
- Problem: A grid of 2 rows and 5 columns is numbered row by row from 1. Each cell (r, c) holds (r·5 + c + 1). What is the value of the cell…
- Problem: Vertices 0–5 are connected by weighted undirected edges: 0-1 (2), 0-2 (4), 1-2 (1), 1-3 (7), 2-4 (3), 3-4 (2), 3-5 (1), 4-5 (5)…
- Problem: Consider the undirected graph with edges 0-1, 1-2, 2-0, 2-3, 3-4 and 4-5, 5-3. A DFS from vertex 0 (visiting neighbours in…
- Problem: Counting sort is applied to [3, 1, 2, 3, 0, 1] with keys in the range 0 to 3. After counting occurrences and computing prefix…
- Problem: The string "aaabbcccc" has its runs counted. What is the length of the longest run of identical characters?