Data Structures & AlgorithmsVery hardCAT · ICPC regional

Problem: The number of ways to arrange the letters of "LEVEL" so that the two E's are not adjacent is what value?

  1. A. 30
  2. B. 12
  3. C. 72
  4. D. 18

Correct answer: D. 18

LEVEL has 5!/(2!·2!) = 30 distinct arrangements; gluing the E's gives 4!/2! = 12, so 30 − 12 = 18. 30 ignores the rule, 12 counts the adjacent ones, and 120 − 48 = 72 forgets the repeated letters.

More Coding Interview Problems questions

Exams that ask this topic