Easy Python 1-D DP, O(len(Nums)*target) Time , O(target) Space
Intuition\n\nFor each new number that comes in, see what new target(sum) can you achieve based on what you have achieved till now. \n# Approach\n Describe your 
# Intuition\n\nFor each new number that comes in, see what new target(sum) can you achieve based on what you have achieved till now. \n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe new target for current iteration (or current new number) is stored in dpnew, whereas dpold stores the old iteration content.\n\nThe DP relation is :\n\n```\ndpnew[nums[i]+j]=max(dpold[nums[i]+j],dpold[j]+1)\n            dpold=dpnew[:]\n```\nwhere j is each number less than target value that you are iterating \n\n# Complexity\n- Time complexity:  $$ O(len(Nums)*target) $$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:  $$ O(target) $$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def lengthOfLongestSubsequence(self, nums: List[int], target: int) -> int:\n        dpold=[0]*(target+1)\n        dpnew=[0]*(target+1)\n        for i in range(len(nums)):\n            \n            if nums[i]<=target:\n                dpnew[nums[i]]=max(dpold[nums[i]],1)\n                for j in range(1,target+1):\n                    if dpold[j] and nums[i]+j<=target:\n                        dpnew[nums[i]+j]=max(dpold[nums[i]+j],dpold[j]+1)\n            dpold=dpnew[:]\n\n        return dpold[-1] if dpold[-1]>0 else -1\n```
['Python3']