← Optiver Interview Insights

Optiver·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Optiver software engineer interview with a combinatorics problem that started simple and then got generalized fast. The math wasn't hard but articulating the justification cleanly under pressure was a different story.

Questions Asked (1)

Q1

Given m copies of 'a' and n copies of 'b', how many distinct strings can you form? Give the closed-form answer and justify it. Then extend the formula to k distinct characters with counts c1 through ck summing to N.

Algorithms & Data Structures
Author's notes

The basic case is just (m+n) choose m, since you're picking positions for the 'a's and the 'b's fill the rest.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by deriving the formula for two characters using the multinomial coefficient: total permutations of m+n items divided by the indistinguishable permutations of each character. Then generalize to k characters by extending the same logic: N! divided by the product of factorials of each count. Justify each step by explaining the division principle and the multiplication principle.

Pro tip: Emphasize that this is the multinomial coefficient and connect it to the binomial coefficient when k=2. Also mention that the formula assumes all characters of the same type are identical, which is key to the division by factorials.

1. Understand the problem

Clarify that we are counting distinct arrangements of m identical 'a's and n identical 'b's, and later k distinct characters with given counts.

2. Derive for two characters

Treat all m+n positions as distinct initially, giving (m+n)! permutations. Then divide by m! and n! to account for identical 'a's and 'b's, yielding (m+n)!/(m! n!).

3. Generalize to k characters

Extend the same reasoning: total permutations of N distinct items is N!, then divide by the product of factorials of each count to remove overcounting from identical items. The formula is N!/(c1! c2! ... ck!).

4. Justify the formula

Explain that each distinct string is counted exactly ∏(ci!) times in the N! permutations, so dividing by that product gives the correct count. This is the multinomial coefficient.

5. Provide examples and edge cases

Illustrate with small numbers (e.g., m=2, n=1 gives 3 strings) and mention that if any ci=0, the term is 1, and the formula still holds.

Key Points to Mention

  • Multinomial coefficient: N!/(c1! c2! ... ck!)
  • Special case k=2 reduces to binomial coefficient (m+n choose m)
  • Division principle: dividing by factorials to account for indistinguishable permutations
  • Assumption that characters of the same type are identical
  • Edge cases: zero counts, all same character
  • Connection to permutations of a multiset

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.