Search
⌘K

Leetcode 2842. Count K-Subsequences of a String With Maximum Beauty

Find the k distinct characters whose counts f(c) in s maximize the sum (beauty), then count how many k-length subsequences (distinct index choices) realize that maximum by resolving ties combinatorially. This reduces to frequency counting, sorting/selecting top-k frequencies, and using combinations/products of f(c) with modular arithmetic to handle tied frequencies.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.