Easy to understand || Dynamic Programming || 0-1 knapsack
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 {\npublic:\n\n    int solve(int ind, int target, vector<int>&nums, vector<vector<int>>&dp){\n        \n        if(target==0) return 0;\n        // if(target<0) return INT_MIN;\n        if(ind<0) return INT_MIN;\n\n        if(dp[ind][target]!=-1) return dp[ind][target];\n\n        int not_take = 0 + solve(ind-1,target,nums,dp);\n        int take = -1e9;\n        if (nums[ind]<=target){\n         take = 1+ solve(ind-1,target-nums[ind],nums,dp);\n        }\n        \n        return dp[ind][target] = max(take,not_take);\n    }\n    int lengthOfLongestSubsequence(vector<int>& nums, int target) {\n        int n = nums.size();\n        vector<vector<int>>dp(n, vector<int>(target+1,-1));\n        int ans = solve(n-1,target,nums,dp);\n        // if(ans<=0) return -1;\n        return max(-1,ans);\n    }\n};\n```
['Array', 'Dynamic Programming', 'Memoization', 'C++']