← 返回 bytedance 的题目列表Longest Repeating Character Replacement
类型:qbank
The unmodified LeetCode 424 prompt: replace at most `k` characters in an uppercase string and return the longest substring that can be made entirely one repeated character.
Requirements
Given an uppercase English string s and an integer k, choose a substring.
Within that substring, replace at most k characters with any uppercase English letter.
Return the maximum possible substring length whose characters can all be made identical.
Examples
Input: s = "ABAB", k = 2
Output: 4
Input: s = "AABABBA", k = 1
Output: 4
Notes
The prompt was the unmodified LC 424 problem.
The round began with a resume drill and a question about how an LLM could be applied to the team's existing system. The coding portion was completed quickly within a 45-minute interview.
Preparation
Derive the window-validity condition in terms of window length, the most frequent character, and the replacement budget.
Practice explaining why the tracked maximum frequency does not need to decrease on every left-boundary move.
Test k = 0, an all-identical string, alternating characters, and a budget larger than the string.