kotlin 100%
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:\nO(n * target)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    fun lengthOfLongestSubsequence(nums: List<Int>, target: Int): Int {\n        var dp = mapOf(0 to 0)\n\n        for (num in nums) {\n            val newDp = dp.toMutableMap()\n            for ((sum, length) in dp) {\n                val newSum = sum + num\n                if (newSum <= target) {\n                    newDp[newSum] = maxOf(newDp.getOrDefault(newSum, 0), length + 1)\n                }\n            }\n            dp = newDp\n        }\n\n        return dp[target] ?: -1\n    }\n}\n```
['Kotlin']