Longest Run of X's
InterviewTime limit1sMemory limit256 MB
Count the longest run of consecutive X marks in each hallway and print its length in the required sentence.
- Level
Easy1 of 10
- Topics
- Array
- Solved
- No attempts yet
Problem
Gru and Lucy are breaking into El Macho's lair. In front of them is a hallway that may be booby-trapped. The hallway is a single row of squares, and every square is marked either X or O. Gru believes that only the squares in the longest run of consecutive X marks are safe.
For each hallway, count how many squares are safe.
Input
The first line contains the number of test cases . is less than 100.
Each of the following lines holds one test case. The first number on the line is the number of squares , followed by strings separated by spaces. Each string is either X or O.
is at least 1, and the sum of over all test cases is at most 200000.
Output
For each test case, find the length of the longest run of consecutive X marks and print one line in this format.
The longest contiguous subsequence of X's is of length L
Write as a plain integer. If the hallway has no X at all, is 0.