Longest Arithmetic Subsequence
Print the length of the longest subsequence (not necessarily contiguous) forming an arithmetic progression.
Input: the first line has N; the second line has N integers.
Output: the longest arithmetic subsequence length.
Constraints:
- 1 ≤ N ≤ 1000
- |ai| ≤ 109
Sample Tests
Input 1
4 3 6 9 12
Output 1
4
Input 2
3 1 2 4
Output 2
2
Discussion (opens after you solve — no spoilers before)
No comments yet.