Minimum Valid Binary Zones
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Minimum Valid Binary Zones
You are given a binary string s and an integer L. Split s into the minimum number of contiguous zones such that every zone has length at most L and is not purely alternating. A one-character zone is considered valid. Return the minimum number of zones.
Examples
Example 1
Input:
0011 4
Output:
1
Explanation: The whole string is valid because it is not purely alternating.
Approach hint
A zone is invalid only when every adjacent pair inside it is different.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp