DP- Bottom Up approach || C#
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(target* nums.Length)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(target* nums.Length)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```csharp []\npublic class Solution {\n    public int LengthOfLongestSubsequence(IList<int> nums, int target) \n    {\n        int[] array = new int[nums.Count];\n        int i =0;\n        foreach(var el in nums)\n        {\n          array[i] = el;\n          i++;\n        }\n\n        return DP(array, target);\n    }\n\n\n    public int DP(int[] nums, int target)\n    {\n        int[][] dp = new int[target+1][];\n\n        for(int i=0;i<dp.Length;i++)\n        {\n            dp[i] = new int[nums.Length+1];\n            dp[i][0] = -1; // Initialize all with -1 to denote unreachable states, this is a condition in the problem sdescription itself.\n        }\n\n        dp[0][0] = 0; // Base case: sum of 0 with 0 elements is achievable with length 0\n\n        for(int j=1;j<dp[0].Length;j++)\n        {\n            dp[0][j] =0;\n        }\n\n        for(int t =1;t<dp.Length;t++)\n        {\n            for(int e = 1; e<dp[0].Length;e++ )\n            {\n                dp[t][e] = dp[t][e-1]; // Option not to take the current element\n                if(nums[e-1]<=t && dp[t - nums[e - 1]][e - 1] != -1)\n                {\n                    dp[t][e] = Math.Max(dp[t-nums[e-1]][e-1]+1, dp[t][e]);  // current is already u[pdated to not take the  current element hence dp[t][e], check line 54.\n                }\n                \n            }\n        }\n\n      // Get the result from the DP table\n    int result = dp[target][nums.Length];\n    return result == -1 ? -1 : result;\n    }\n}\n```
['C#']