Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 900 Bytes

_2379. Minimum Recolors to Get K Consecutive Black Blocks.md

File metadata and controls

35 lines (25 loc) · 900 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : March 08, 2025

Last updated : March 08, 2025


Related Topics : String, Sliding Window

Acceptance Rate : 68.48 %


Solutions

Python

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