C++ DP Solution :)
To build a subsequence for every element in the array we have to branch decisions :\n1 => include the element in the sequence\n2 => Dont include the element\n1 
To build a subsequence for every element in the array we have to branch decisions :\n1 => include the element in the sequence\n2 => Dont include the element\n1 => If we decide to include de element, this means the sums towards target grows with sum + nums[i] or target - nums[i],same thing, i find target - nums[i] more convenient.\nSome of these branches will be "invalid" when target - nums[i] <0, these are decision branches that go past the target and therefore are not to be considered. since we are counting the length we do 1 + LLS(i - 1, target - nums[i])\n2=> if we dont include, we basically skip the element at i by ingoring it and just calling LLS(i-1, target) leaving the sum untouched.\nAt the end we are intrested int the longest solution so we return the max of our branches: max(include, skip)\n# Code\n```\nclass Solution {\npublic:\nint lengthOfLongestSubsequence(const vector<int>& nums, int target){\n    size_t n = nums.size();\n\n    vector<vector<int>> dp(n, vector<int>(target + 1, INT_MIN));\n\n    for(int i = 0; i < n; i++){\n        dp[i][0] = 0;\n    };\n\n    if(nums[0] <= target){\n        dp[0][nums[0]] = 1;\n    }\n\n    for(int i = 1; i < n; i++){\n        for(int t = 0; t <= target; t++){\n            int pick = INT_MIN;\n            if(nums[i] <= t){\n                pick = 1 + dp[i - 1][t - nums[i]];\n            }\n\n            int skip = dp[i - 1][t];\n\n            dp[i][t] = max(skip, pick);\n        }\n    }\n\n    return dp[n-1][target] < 0 ? -1 : dp[n-1][target];\n};\n};\n```
['C++']