Bottom Up Solution || CPP
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, INT_MIN));\n\n        // Initialize dp[i][0] to 0 for all i because target 0 can be achieved with an empty subsequence\n        for (int i = 0; i <= n; i++) {\n            dp[i][0] = 0;\n        }\n\n        // Fill the DP table\n        for (int i = 1; i <= n; i++) {\n            for (int j = 0; j <= target; j++) {\n                // If we do not take the current number\n                dp[i][j] = dp[i - 1][j];\n\n                // If we take the current number\n                if (j >= nums[i - 1] && dp[i - 1][j - nums[i - 1]] != INT_MIN) {\n                    dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - nums[i - 1]]);\n                }\n            }\n        }\n\n        int res = dp[n][target];\n        return (res > 0) ? res : -1;\n    }\n};\n\n```
['C++']