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?

  1. A. 24
  2. B. 216
  3. C. 6
  4. 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

Exams that ask this topic