Data Structures & AlgorithmsModerateCAT · TCS NQT

Problem: A set of letters {A, B, C, D, E} is arranged in a row. How many arrangements have A immediately to the left of B?

  1. A. 48
  2. B. 24
  3. C. 120
  4. D. 60

Correct answer: B. 24

Glue AB into one block (order fixed): 4! = 24 arrangements. Allowing BA too gives 48, 120 counts all arrangements, and 60 counts A anywhere to the left of B.

More Coding Interview Problems questions

Exams that ask this topic