Answer: PEPPERFRY Hiring | Online Assessment Question | On-Campus (2024)

Answer · Posted Jun 2026

Approach Use a Sliding Window of size k. For every window: Count white blocks. White blocks indicate recolor operations needed. Maintain the minimum white count across all windows. The minimum whites found equals the answer. Strategy Sliding Window. Track white blocks in current window. Update minimum white count whenever window size reaches k. Java Code class Solution { public int minimumRecolors(String blocks, int k) { int whites = 0; int minWhites = Integer.MAX_VALUE; for (int i = 0; i < ...

The full answer & interview discussion are available to premium members.

Log in Create a free account