#K45317. Longest Unique Adjacent Segment
Longest Unique Adjacent Segment
Longest Unique Adjacent Segment
You are given several test cases. In each test case, you are provided with a sequence of integers representing the colors of flowers. Your task is to find the length of the longest contiguous segment in the sequence such that no two adjacent flowers have the same color.
Formally, for each test case, given an integer \( n \) and a sequence \( a_1, a_2, \dots, a_n \), determine the maximum length of a segment \( [l, r] \) (\( 1 \leq l \leq r \leq n \)) such that for every \( i \) with \( l < i \leq r \), \( a_i \neq a_{i-1} \).
Input Format: The input begins with an integer \( T \), the number of test cases. Each test case consists of an integer \( n \) on a separate line followed by a line with \( n \) space-separated integers representing the array of colors.
Output Format: For each test case, output the length of the longest segment that satisfies the condition. Each answer should be printed on its own line.
inputFormat
The first line of input contains an integer \( T \) denoting the number of test cases. For each test case, the first line contains an integer \( n \) (the number of flowers). The second line contains \( n \) space-separated integers representing the colors of the flowers.
outputFormat
For each test case, output a single integer on a new line representing the maximum length of a contiguous segment where no two adjacent values are equal.
## sample1
5
1 2 2 3 4
3
</p>