As reported: DigitalOcean SSE 2 onsite loop (DBaaS team), DSA round (2026): two LeetCode problems, this one and the circular house-robber problem.
You are given a string s of uppercase English letters and an integer k. You may choose any character of the string and change it to any other uppercase letter, at most k times in total. Return the length of the longest substring containing only one repeated letter that you can get.
This is LeetCode 424 — Longest Repeating Character Replacement.
Example 1
s = "ABAB", k = 2 -> 4 change both A's (or both B's)
Example 2
s = "AABABBA", k = 1 -> 4 change the middle A: "AABBBBA" has "BBBB"
Constraints: 1 ≤ s.length ≤ 10^5; s has only uppercase English letters; 0 ≤ k ≤ s.length.
Code runner format: two lines, s (a JSON string) then k. Implement characterReplacement(s, k); the harness prints the length.