dsa2 min read
Longest Arithmetic Subsequence — DP + Hash Map per Index
Find the longest arithmetic subsequence using dp[i][diff] = length ending at index i with given difference.
Read →
webcoderspeed.com
2 articles
Find the longest arithmetic subsequence using dp[i][diff] = length ending at index i with given difference.
Prevent integer overflow in competitive programming: safe multiplication, __int128, binary search on answers, and floating-point gotchas.