2303. Unique Substrings With Equal Digit Frequency

Medium
Hash Table
String
Rolling Hash
Counting
Hash Function

Description

Hints

Hint 1
With the constraints, could we try every substring?
Hint 2
Yes, checking every substring has runtime O(n^2), which will pass.
Hint 3
How can we make sure we only count unique substrings?
Hint 4
Use a set to store previously counted substrings. Hashing a string s of length m takes O(m) time. Is there a fast way to compute the hash of s if we know the hash of s[0..m - 2]?
Hint 5
Use a rolling hash.

Statistics

Acceptance
64.4%
Submissions
14,958
Accepted
9,627