Simple to understand. Just follow the hints.
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int longestSubsequence(vector<int>& nums) {
        reverse(nums.begin(), nums.end());
        vector<vector<int>> dp(nums.size(), vector<int>(301));
        vector<int> mapp(301, -1);

        // maximum sub sequence size with difference = index i in the dp.
        int ans = 0;
        for(int i = 0; i < nums.size(); i ++) {
            for(int j = 1; j <= 300; j ++) {
                if(mapp[j] != -1) {
                    dp[i][abs(nums[i] - j)] = max(dp[i][abs(nums[i] - j)], dp[mapp[j]][abs(nums[i] - j)] + 1);
                }
            }

            for(int j = 1; j <= 300; j ++) {
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            }
            mapp[nums[i]] = i;
            ans = max(ans, dp[i][300] + 1); 
        }

        return ans;
    }
};
```
['C++']