Easy Iterative Dp Solution
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```cpp []\nclass Solution {\npublic:\n    int lengthOfLongestSubsequence(vector<int>& nums, int target) {\n        int n = nums.size();\n        vector<vector<int> > dp(n+1, vector<int> (target+1, -1));\n\n        dp[0][0] = 0;\n        for(int i = 1; i <= n; i++){\n            for(int j = 0; j <= target-nums[i-1]; j++){\n                if(dp[i-1][j] != -1) dp[i][j+nums[i-1]] = max(dp[i][j+nums[i-1]], dp[i-1][j] + 1);              \n            }\n            for(int j = 0; j <= target; j++){\n                dp[i][j] = max(dp[i][j], dp[i-1][j]);\n            }\n        }\n\n        return dp[n][target];\n    }\n};\n```
['Array', 'Dynamic Programming', 'C++']