Longest arithmetic progression subsequence
Your task
Given an integer array nums, return the length of the longest subsequence whose consecutive elements form an arithmetic progression (constant difference). A single element counts as length 1. 1 <= len(nums) <= 1000, -10^4 <= nums[i] <= 10^4.
Examples
longest_arith_subseq(nums: list[int]) -> intExample 1
Input
longest_arith_subseq([3, 6, 9, 12])Output
4