dp ^^
\nint lengthOfLongestSubsequence(vector<int>& n, int t)\n{\n\tint dp[1001]{1};\n\tfor(const auto & n : n)\n\t\tfor(int i(t); i; --i)\n\t\t\tif(i>=n and dp[i-n])
```\nint lengthOfLongestSubsequence(vector<int>& n, int t)\n{\n\tint dp[1001]{1};\n\tfor(const auto & n : n)\n\t\tfor(int i(t); i; --i)\n\t\t\tif(i>=n and dp[i-n]) dp[i] = max(dp[i], 1+dp[i-n]);\n\treturn dp[t]-1;\n}\n```\n**Similar problems:**\n[322. Coin Change](https://leetcode.com/problems/coin-change/discuss/5492970/dp)\n[518. Coin Change II](https://leetcode.com/problems/coin-change-ii/discuss/5487668/ok)\n[2915. Length of the Longest Subsequence That Sums to Target](https://leetcode.com/problems/length-of-the-longest-subsequence-that-sums-to-target/discuss/5492962/dp)\n[3183. The Number of Ways to Make the Sum](https://leetcode.com/problems/the-number-of-ways-to-make-the-sum/discuss/5306467/one-liner)\n[300. Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/discuss/1288420/dp)
['C', 'C++']