Easy Recursion + Memo code
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: O(N*Target)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N*Target)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int dfs(int target,int i,vector<int> &nums,vector<vector<int>> &dp){\n        if(target == 0) return 0;\n        if(i == size(nums)) return INT_MIN;\n        if(dp[i][target] != -1) return dp[i][target];\n        if(target >= nums[i]) return dp[i][target] = max(1+dfs(target-nums[i],i+1,nums,dp),dfs(target,i+1,nums,dp));\n        return dp[i][target] = dfs(target,i+1,nums,dp);\n    }\n    int lengthOfLongestSubsequence(vector<int>& nums, int target) {\n        int n = size(nums);\n        vector<vector<int>> dp(n+1,vector<int>(target+1,-1));\n        int ans =  dfs(target,0,nums,dp);\n        if(ans < 0) ans = -1;\n        return ans;\n    }\n};\n```
['Array', 'Dynamic Programming', 'C++']