#C11917. Longest Consecutive Minute Intervals

    ID: 41286 Type: Default 1000ms 256MiB

Longest Consecutive Minute Intervals

Longest Consecutive Minute Intervals

You are given a sequence of event timestamps for multiple test cases. In each test case, the events occur at specific timestamps (in minutes). Your task is to determine the length of the longest subsequence of events such that each event occurs exactly one minute after the previous one. In other words, if the events in the subsequence occur at times \(a, a+1, a+2, \dots, a+k\), then its length is \(k+1\).

Input Format: The input starts with an integer \(T\) indicating the number of test cases. For each test case, the first line contains an integer \(n\) representing the number of events. The following line contains \(n\) space-separated integers representing the timestamps of the events.

Output Format: For each test case, print a single line containing the length of the longest consecutive sequence of minute intervals.

inputFormat

The first line of input consists of an integer (T) denoting the number of test cases. For each test case, the first line contains an integer (n) indicating the number of events. The second line contains (n) space-separated integers that represent the timestamps of the events.

outputFormat

For each test case, output a single line containing the maximum length of a sequence where each event occurs exactly one minute after the previous event.## sample

2
5
1 2 3 5 6
4
10 12 13 14
3

3

</p>