java | easy to understand
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int lengthOfLongestSubsequence(List<Integer> nums, int target) {\n        int[] dp = new int[target+1];\n        for(int i=0;i<=target;i++)\n            dp[i]=-1;\n        \n        Collections.sort(nums);\n        dp[0]=0;\n        int n = nums.size();\n        for(int i=0;i<n;i++){\n            for(int j=target-nums.get(i);j>=0;j--){\n                if(dp[j]>=0){\n                    dp[j+nums.get(i)] = Math.max(dp[j+nums.get(i)], dp[j]+1);\n                }\n            }\n        }\n        return dp[target];\n        \n        \n    }\n}\n```
['Java']