Approach hintTry it first, then revealHide
Solve the problem once for each target letter: find the longest window that contains at most k occurrences of the other letter, using the usual grow-and-shrink scan.
Solve the problem once for each target letter: find the longest window that contains at most k occurrences of the other letter, using the usual grow-and-shrink scan.