🔥 🔥 Simple Java solution beats 100%
\n\n# Code\n\nclass Solution {\n    public int[] answerQueries(int[] nums, int[] queries) {\n\n        int n = nums.length;\n        int m = queries.length;\n  
\n\n# Code\n```\nclass Solution {\n    public int[] answerQueries(int[] nums, int[] queries) {\n\n        int n = nums.length;\n        int m = queries.length;\n        int[] answer = new int[m];\n  \n // sort nums in non-decreasing order\n         Arrays.sort(nums);\n  \n  // for each query, find the maximum size of a subsequence that has a sum less than or equal to the query\n        for (int i = 0; i < m; i++) {\n          int query = queries[i];\n          int sum = 0;\n          int size = 0;\n             for (int j = 0; j < n; j++) {\n                sum += nums[j];\n                if (sum > query) {\n                 break;\n                 }\n                 size++;\n             }\n        answer[i] = size;\n  }\n  \n  return answer;\n    }\n}\n```
['Java']