Simple easy java
\n\n# java\n\n\n\nclass Solution {\n    int[][] dp;\n\n    public int solve(int i, List<Integer> v, int t) {\n        if (t == 0)\n            return 0;\n      
\n\n# java\n```\n\n\nclass Solution {\n    int[][] dp;\n\n    public int solve(int i, List<Integer> v, int t) {\n        if (t == 0)\n            return 0;\n        if (t < 0 || i >= v.size())\n            return Integer.MIN_VALUE;\n        if (dp[i][t] != -1)\n            return dp[i][t];\n        int a = 1 + solve(i + 1, v, t - v.get(i));\n        int b = solve(i + 1, v, t);\n        return dp[i][t] = Math.max(a, b);\n    }\n\n    public int lengthOfLongestSubsequence(List<Integer> v, int t) {\n        int n = v.size();\n        dp = new int[n + 1][t + 1];\n        for (int[] row : dp)\n            Arrays.fill(row, -1);\n        int ans = solve(0, v, t);\n        if (ans <= 0)\n            return -1;\n        return ans;\n    }\n}\n\n```
['C', 'C++', 'Java', 'Python3']