Data Structures & AlgorithmsHardCAT · TCS NQT

Problem: A row of 5 seats is filled by 3 distinct people, leaving 2 seats empty. How many arrangements are possible if the empty seats must be adjacent?

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

Correct answer: D. 24

The adjacent empty pair can sit in 4 places and the 3 people fill the rest in 3! = 6 ways: 24. Without the constraint P(5,3) = 60, 6 forgets the 4 placements, and 48 treats the two empty seats as distinguishable.

More Coding Interview Problems questions

Exams that ask this topic