PEPPERFRY Hiring | Online Assessment Question | On-Campus (2024)
Question · Posted Jun 2026
Problem: Minimum Recolors to Get K Consecutive Black Blocks You are given: A string blocks consisting of 'B' and 'W' An integer k In one operation, you can recolor a white block (W) into a black block (B). Return the minimum number of recolors required so that there exists at least one substring of length k containing only black blocks. Example Input blocks = "WBBWWBBWBW" k = 7 Output 3 Explanation Possible window: WBBWWBB Contains: W = 3 Recolor these ...
The full answer & interview discussion are available to premium members.
Log in Create a free account