Chotu और अज़्काबान का क़ैदी

3.8

6 votes
Easy
Problem

"A Patronus is a kind of positive force, and for the wizard who can conjure one, it works something like a shield, with the Dementor feeding on it, rather than him. In order for it to work, you need to think of a memory. Not just any memory, a very happy memory, a very powerful memory…" -Remus Lupin

enter image description here

Chotu has been ambushed by Dementors and as told by professor Lupin he can only fight them using the Patronas charm. Chotu has memories in form of binary strings (consisting of 0's and 1's only), and he needs to find out the most powerful memory. The most powerful memory is the longest substring of alternate 0's and 1's.
As Chotu is in deep trouble he needs your help to find out the most powerful memory he has as quickly as possible.



Input
First line of input contains an integer T denoting number of test cases.
Next T lines contains a string S consisting of 0's and 1's denoting Chotu's memory.

Output
For each test case output the length of the most powerful memory.

Constraints
1 <= T <= 100
1 <= |S| <= 105

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For the First sample case longest substring of alternate 0's and 1's is "101".
For the second case the longest substring of alternate 0's and 1's is "01".

Editor Image

?