Compute permutations with repeated letters

Quick Overview

This question evaluates combinatorics and counting principles within the Statistics & Math domain, focusing on permutations with repeated characters and the generalization to multiple symbol counts.

Compute permutations with repeated letters

Company: Optiver

Role: Software Engineer

Category: Statistics & Math

Difficulty: easy

Interview Round: Take-home Project

Given two nonnegative integers m and n, how many distinct strings can be formed that contain exactly m copies of the character 'a' and n copies of the character 'b'? Provide the closed-form count and a short justification. Then generalize your answer to an alphabet with k distinct characters occurring with counts c1, c2, ..., ck (sum ci = N), and give the corresponding formula.

Quick Answer: This question evaluates combinatorics and counting principles within the Statistics & Math domain, focusing on permutations with repeated characters and the generalization to multiple symbol counts.

|Home/Statistics & Math/Optiver
Optiver logo
Optiver
Aug 13, 2025, 12:00 AM
easySoftware EngineerTake-home ProjectStatistics & Math
11
0

Counting Strings with Repeated Characters

Problem

Given two nonnegative integers m and n, how many distinct strings can be formed that contain exactly m copies of the character 'a' and n copies of the character 'b'? Provide the closed-form count and a short justification.

Then generalize your answer to an alphabet with k distinct characters occurring with counts c1, c2, ..., ck (with c1 + c2 + ... + ck = N), and give the corresponding formula.

Loading comments...