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?
- A. 34650
- B. 69300
- C. 138600
- 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
- Problem: What is the maximum total of two non-overlapping subarrays of length 2 in [1, 5, 2, 8, 3]? Run the code. python a = [1, 5, 2, 8…
- Problem: How many integers in [1, 1000] have digit sum equal to 5 and are divisible by 5? Run the code. python print(sum(1 for x in…
- Problem: Which algorithm computes the number of shortest paths between all pairs in an unweighted graph in O(V E)?
- Problem: What is the time complexity of Kadane's algorithm extended to 2D (maximum-sum submatrix) with an n x n matrix?
- Problem: A hash table uses chaining, and every insertion first scans the key’s chain to make sure the key is not already present. What is…
- Problem: Which problem does the 'LCA by Euler tour and RMQ' reduce to?