#C4910. Longest Bouquet

    ID: 48501 Type: Default 1000ms 256MiB

Longest Bouquet

Longest Bouquet

Alice has received a number of flowers, where each flower is represented by an integer indicating its species. A bouquet is defined as a contiguous subsequence of flowers that are all of the same species. Your task is to determine the length of the longest bouquet that can be formed from the given sequence for each test case.

Formally, for an array of flower species \(a_1, a_2, \ldots, a_n\), you need to find the maximum \(k\) such that there exists an index \(i\) with \(a_i = a_{i+1} = \cdots = a_{i+k-1}\). You will be given multiple test cases.

Note: The input is provided via stdin and the output should be written to stdout.

inputFormat

The first line contains an integer \(T\) (\(1 \leq T \leq 100\)), the number of test cases. For each test case:

  • The first line contains an integer \(n\) (\(1 \leq n \leq 10^5\)), the number of flowers.
  • The second line contains \(n\) space-separated integers representing the species of the flowers.

It is guaranteed that the total number of flowers over all test cases does not exceed \(10^6\).

outputFormat

For each test case, output a single integer on a new line: the length of the longest bouquet (i.e. the maximum count of consecutive identical flowers).

## sample
3
5
1 2 2 3 3
4
4 4 4 4
8
1 2 3 4 5 6 7 8
2

4 1

</p>