Python data engineering interview problem. Difficulty: intermediate. Pattern: Sliding Window. About 14 minutes. Part of the Pro drill bank.
Longest same-letter window after at most k replacements. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement character_replacement(s: str, k: int) -> int.
Input: character_replacement('ABAB', 2) Output: 4 Replace both B or both A.
Topics: lakebench, python, window, replace.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Longest same-letter window after at most k replacements.
Implement `character_replacement(s: str, k: int) -> int`. Example: `"ABAB", 2` → `4`. Keep the harness.