Practice Maximum Difference Between Even and Odd Frequency II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Difference Between Even and Odd Frequency II
Problem Statement
Given s and k, consider substrings of length at least k. In a chosen substring, select a character a with odd frequency and a different character b with positive even frequency. Maximize freq[a] - freq[b] and return that difference. The substring may contain other characters as well.
Source: Maximum Difference Between Even and Odd Frequency II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "12233", k = 4
-1
# Example 2
s = "1122211", k = 3
1
# Example 3
s = "110", k = 3
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Difference Between Even and Odd Frequency II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.