Given a string s
consisting of digits from '0'
to '9'
.
A string is called good if the frequency of each digit present in the string is the same.
Return the number of unique good substrings of s
.
Example 1:
Input: s = "1212" Output: 5 Explanation: The good substrings are "1", "2", "12", "21", "1212". Note that "12" and "21" are different substrings, but they are equal as strings, so they are only counted once in the set of unique good substrings.
Example 2:
Input: s = "112233" Output: 7 Explanation: The good substrings are "1", "11", "2", "22", "3", "33", "112233".
Example 3:
Input: s = "111" Output: 3 Explanation: The good substrings are "1", "11", "111".
Constraints:
1 <= s.length <= 2500
s
consists of digits from '0'
to '9'
.