Zero Game
InterviewTime limit1sMemory limit512 MB
Given a binary string and Q values K, find for each K the longest run of zeros that can be formed with at most K moves of single characters.
- Level
Medium4 of 10
- Topics
- Sliding window, String, Two pointers
- Solved
- No attempts yet
Problem
You are given one string consisting of only 0 and 1. You are bored, so you start to play with the string. In each operation, you can move any character of this string to another position in the string. For example, suppose 0010. Then you can move the first zero to the tail, and becomes 0100.
You also have numbers . For each , find the maximum number of consecutive zeroes the string can have if you start with and use at most operations.
Input
The first line contains the string . The second line contains the integer . Each of the following lines contains one integer .
Output
For each query, print the answer on its own line.
Constraints
, where is the length of . consists of only 0 and 1. , , .