Longest Arithmetic Stretch
Find the longest CONTIGUOUS stretch that forms an arithmetic progression (constant difference).
Input: the first line has N; the second line has N integers.
Output: the maximum AP stretch length (any 1 or 2 elements always qualify).
Constraints:
- 1 ≤ N ≤ 105
- |ai| ≤ 109
Sample Tests
Input 1
7 3 5 7 9 2 4 6
Output 1
4
Input 2
2 1 9
Output 2
2
Discussion (opens after you solve — no spoilers before)
No comments yet.