#C10323. Longest Consistent Subplaylist
Longest Consistent Subplaylist
Longest Consistent Subplaylist
Given a playlist of songs with their rhythm values, your task is to determine the length of the longest contiguous subplaylist where the difference between consecutive songs is constant. In other words, you need to find the maximum length of an arithmetic progression that appears consecutively in the playlist.
For each test case, you are given an integer N indicating the number of songs, followed by a line of N integers representing the rhythm values of the songs. You should compute, for each test case, the length of the longest subplaylist that forms an arithmetic progression.
The arithmetic progression condition can be expressed in LaTeX as follows:
$$a_{i} - a_{i-1} = d \quad \text{for all valid } i,$$
where d is a constant difference. If the playlist contains only a single song, consider the longest subplaylist length as 1.
inputFormat
The first line of input contains an integer T, representing the number of test cases. Each test case consists of two lines:
- The first line contains an integer N representing the number of songs.
- The second line contains N space-separated integers, the rhythm values of the songs.
It is guaranteed that N ≥ 1.
outputFormat
For each test case, output a single line containing the length of the longest consistent subplaylist (i.e., the longest contiguous arithmetic progression) found in the playlist.
## sample2
6
1 2 3 4 5 6
5
10 20 30 25 20
6
3
</p>