Description
You are given a string s. A split is good if you can split s into two non-empty strings where the number of distinct letters in the left substring equals the number of distinct letters in the right substring. Return the number of good splits.
Examples
Input:
s = "aacaba"Output:
2Explanation:
aaca|ba and aac|aba are good.
Input:
s = "a"Output:
0Explanation:
Edge case with a single character.
Input:
s = "abcabc"Output:
1Explanation:
A good split has equal distinct character counts on both sides. For "abcabc": a|bcabc (1 vs 3), ab|cabc (2 vs 3), abc|abc (3 vs 3), abca|bc (3 vs 2), abcab|c (3 vs 1). Only abc|abc has equal counts, so there is 1 good split.
Constraints
- •
1 ≤ s.length ≤ 10^5