Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use dynamic programming.
Let dp[i] be the maximum length of a subsequence of the given difference whose last element is i.
dp[i] = 1 + dp[i-k]
Solve with full IDE support and test cases