Hi everyone,
I am pretty new to dynamic programming, and I have been struggling with the following problem:
Given an array of integers, how can I find the longest contiguous arithmetic subsequence? For instance, if our entries are 10, 3, 5, 7, 9, 11, 5, 8, 7, 13, 14, then I would have to return "5" since 3, 5, 7, 9, 11 forms the longest contiguous arithmetic subsequence.
I thought about defining dp[i][j] to be the longest contiguous arithmetic subsequence ending at index i with common difference equal to j, but I can't really come up with the transitions properly.
I would really appreciate it if someone could please help me with this problem.