2683. Count the Number of Good Subsequences

Medium
Hash Table
Math
String
Combinatorics
Counting

Description

Hints

Hint 1
Use the frequency array of characters of the string.
Hint 2
For 1 ≤ m ≤ s.length, count the number of subsequences of s where each character occurs exactly m times.
Hint 3
For any n and k, you can calculate (n choose k) mod p in O(log p) using binary exponentiation.

Statistics

Acceptance
48.6%
Submissions
8,024
Accepted
3,899