Given an integer array arr and an integer difference, find the length of the longest arithmetic subsequence in arr such that the difference between any two consecutive elements in the subsequence is equal to difference.
A subsequence is a sequence derived from arr by deleting zero or more elements without changing the relative order of the remaining elements.
Constraints:
arr.length
arr[i], difference
Given an integer array arr and an integer difference, find the length of the longest arithmetic subsequence in arr such that the difference between any two consecutive elements in the subsequence is equal to difference.
A subsequence is a sequence derived from arr by deleting zero or more elements without changing the relative order of the remaining elements.
Constraints:
arr.length
arr[i], difference