Leetcode June 11, 2025 -- Problem #3445
Today's problem is #3445: Maximum Difference Between Even and Odd Frequency II. https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-ii/description/ This builds off of yesterday's problem. Notice, first of all, that the substring *subs* can be any size from k to len(s). At first glance, you might think this means that the largest difference will always come from the largest valid substring where there exists both an even and odd frequency -- I thought the same thing. However, with a little more thought, we can see that that might not always be true. Take for example, the case s = "1121122" . The frequency of 1 is 4, and the frequency of 2 is 3, so the maximum difference is 1. However, look at the substring s[0:5] , which is "11211". Here, the frequency of 1 is 4, and the frequency of 2 is 1, so the maximum difference is 3. The obvious approach is to just run every substring through yesterday's maxDifference function, and then...