✅✅✅ SIMPLE JAVA 7ms SOLUTION EXPLAINED || Faster than 86% ✔
Runtime: 7 ms, faster than 86.21% of Java online submissions for Longest Subsequence With Limited Sum.\nMemory Usage: 42.6 MB, less than 97.41% of Java online s
**Runtime: 7 ms, faster than 86.21% of Java online submissions for Longest Subsequence With Limited Sum.\nMemory Usage: 42.6 MB, less than 97.41% of Java online submissions for Longest Subsequence With Limited Sum.**\n\n#### Steps:\n1. sort nums\n2. loop through queries\n3. count the maximum amount of numbers that still make the sum <= queries[i]\n4. add to answer\n\nJava code:\n```\n    public int[] answerQueries(int[] nums, int[] queries) {\n        int[] answer = new int[queries.length];\n        Arrays.sort(nums);\n        for (int i = 0; i < queries.length; i++) {\n            long sum = 0L;\n            int j = 0;\n            while (j<nums.length && sum+nums[j]<=queries[i]) {\n                sum+=nums[j];\n                j++;\n            }\n            answer[i] = j;\n        }\n        return answer;\n    }\n```
['Sorting', 'Java']