String Conversion and Queries 2
InterviewTime limit3sMemory limit512 MB
Apply character replacement queries to a string, and after each type 2 query print the longest run of one repeated character.
- Level
Easy3 of 10
- Topics
- String, Implementation, Brute force
- Solved
- No attempts yet
Problem
A string consisting of uppercase and lowercase English letters is given. A list of queries on is also given. Each query is one of two types.
- Type 1, written as
1 i1 i2: Replace every character in with the character . If has no character , does not change. - Type 2, written as
2: Apply all type 1 queries given so far to , in order. Let be the resulting string. Output the maximum length of a substring of made of one repeated character. A substring is a contiguous part of .
Process the queries in from first to last and output the result of each type 2 query.
Input
The first line contains the string and the integer , separated by a space.
Each of the next lines contains one query, in order from the first to the last. A type 1 query is given as the integer 1 followed by the characters and , separated by spaces. A type 2 query is given as the integer 2 alone.
Output
For each type 2 query, print its result on its own line, in order.
Constraints
- , where consists of uppercase and lowercase English letters.
- .
- contains only type 1 and type 2 queries.
- contains at least one type 2 query.
- (the number of type 2 queries) .
- and are uppercase or lowercase English letters.