Question bank › Sliding Window
Dsa Sliding Window Hard

Find the Maximum Length of Repeated Characters in K Changes

You are given a string `s` of lowercase letters and an integer `k`. You can change up to `k` characters in the string to make all characters in a substring the same. Your task is to find the length of the longest substring that can be obtained after performing at most `k` changes. Input: - A single line containing the string `s`. - A single integer `k`. Output: - An integer representing the maximum length of the substring after `k` changes. Example: Input: abaa 1 Output: 4 In this example, we can change one 'b' to 'a' to form 'aaaa', resulting in a length of 4.

Key concepts

sliding_windowarraysgreedy

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.