Find the maximum value of a substring score based on the difference between the frequency of one character with even count and another character with odd count, under the problem's window constraints.
You are given a string s and an integer k.
Consider a substring of s that satisfies the required length constraint from the problem. For that substring, choose two different characters:
The value of the substring is the difference between these two frequencies.
Your task is to compute the maximum possible value over all valid substrings and all valid choices of characters.
Because the exact parity conditions depend on the substring frequencies, the key challenge is to efficiently evaluate many candidate substrings without checking every character count from scratch each time.
s.k.The exact interpretation of the valid substring length/constraint follows the original problem setting on LeetCode.
1 <= |s| <= $10^{5}$ is a reasonable working assumption for this problem family.k is a positive integer.Example 1
Input
s = "12233", k = 2
Output
1
Explanation
One valid substring is "2233". Its character frequencies can make the difference between an even-frequency character and an odd-frequency character equal to 1, which is the best achievable for this example.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.