Data Structures & AlgorithmsHardCAT · TCS NQT

Problem: The number of permutations of the digits 1, 2, 3, 4 in which the digit 1 is not in the first position and 4 is not in the last position is what value?

  1. A. 12
  2. B. 14
  3. C. 18
  4. D. 24

Correct answer: B. 14

Inclusion-exclusion: 24 − 6 − 6 + 2 = 14. Forgetting to add back the 2 permutations with both gives 12, applying only one restriction gives 18, and 24 ignores both.

More Coding Interview Problems questions

Exams that ask this topic