Leetcode 1330 Solution
This article provides solution to leetcode question 1330 (longest-arithmetic-subsequence-of-given-difference)
Access this page by simply typing in "lcs 1330" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
class Solution: def longestSubsequence(self, arr: List[int], difference: int) -> int: m = collections.defaultdict(int) for v in arr: m[v] = m[v - difference] + 1 if v - difference in m else 1 return max(m.values())