Compute permutations with repeated letters
OptiverSoftware Engineer · Online AssessmentLast updated
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.
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.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.