All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : March 08, 2025
Last updated : March 08, 2025
Related Topics : String, Sliding Window
Acceptance Rate : 68.48 %
class Solution:
def minimumRecolors(self, blocks: str, k: int) -> int:
output = w = blocks[:k].count('W')
for l, r in zip(blocks, blocks[k:]) :
w += (r == 'W') - (l == 'W')
output = min(output, w)
return output