JS very easy and fast solution
\n\n# Code\n\n/**\n * @param {number[]} nums\n * @param {number[]} queries\n * @return {number[]}\n */\nvar answerQueries = function(nums, queries) {\n    nums 
\n![image.png](https://assets.leetcode.com/users/images/d411a60e-cd1b-4e51-94fa-bb50d3e96e6d_1667547883.015785.png)\n# Code\n```\n/**\n * @param {number[]} nums\n * @param {number[]} queries\n * @return {number[]}\n */\nvar answerQueries = function(nums, queries) {\n    nums = nums.sort((a, b) => a-b);\n    const output = [];\n\n    for (let i = 0; i < queries.length; i++) {\n        const target = queries[i];\n        let sum = 0;\n        for (let j = 0; j < nums.length; j++) {\n            sum += nums[j];\n            if (sum > target) {\n                output.push(j)\n                break;\n            }\n        }\n        if (output[i] === undefined) output.push(nums.length);\n    }\n\n    return output;\n};\n```
['JavaScript']