Number of Good Ways to Split a String
You are given a string s consisting of lowercase English letters.
A good way to split the string is to partition it into two non-empty substrings left and right such that the number of distinct characters in left is equal to the number of distinct characters in right.
Return the number of good ways to split s.
Examples
Input: "aacaba"
Output: 2
Input: "abcd"
Output: 1
Hints
Precompute two arrays: `prefix[i]` (bitmask of distinct characters in `s[0..i-1]`) and `suffix[i]` (bitmask of distinct characters in `s[i..n-1]`).
For each possible split position `i` (1 ≤ `i` ≤ `n-1`), check if `prefix[i] == suffix[i]` using bitwise comparison.
Optimize by tracking the frequency of each bitmask in `prefix` and `suffix` to avoid recomputing for every split position.
Number of Good Ways to Split a String
You are given a string `s` consisting of lowercase English letters.