Data Structures & AlgorithmsHardProduct Company SDE · CP practice

Problem: How many distinct arrangements of the letters of 'MISSISSIPPI' exist? Run the code.

Problem: How many distinct arrangements of the letters of 'MISSISSIPPI' exist? Run the code.
import math
print(math.factorial(11) // (math.factorial(4) * math.factorial(4) * math.factorial(2)))
What is printed?
  1. A. 34650
  2. B. 69300
  3. C. 138600
  4. D. 39916800

Correct answer: A. 34650

11!/(4!·4!·2!) = 34650, dividing by the factorial of each letter's count. Forgetting the 2! for P gives 69300, using 3! for one of the 4s gives 138600, and 11! treats all letters as distinct.

More Coding Interview Problems questions

Exams that ask this topic