Beginner friendly [Java/JavaScript/Python] Solution
Time Complexity : O(n^2)\n\njava []\nclass Solution {\n    public int[] answerQueries(int[] nums, int[] queries) {\n        Arrays.sort(nums);\n        int arr[
**Time Complexity : O(n^2)**\n\n```java []\nclass Solution {\n    public int[] answerQueries(int[] nums, int[] queries) {\n        Arrays.sort(nums);\n        int arr[] = new int[queries.length];\n        for(int j=0; j<queries.length; j++){\n            int count = 0, sum=0;\n            for(int i=0; i<nums.length; i++){\n                if(sum + nums[i] <= queries[j]){\n                    sum += nums[i];\n                    count++;\n                }\n            }\n            arr[j] = count;\n        }\n        return arr;\n    }\n}\n```\n```javascript []\nvar answerQueries = function(nums, queries) {\n    nums.sort((a,b) => a-b)\n    let arr = []\n    for(let query of queries){\n        let count = 0, sum=0\n        for(let i=0; i<nums.length; i++){\n            if(sum + nums[i] <= query){\n                sum += nums[i]\n                count++\n            }\n        }\n        arr.push(count)\n    }\n    return arr\n};\n```\n```python []\nclass Solution(object):\n    def answerQueries(self, nums, queries):\n        nums.sort()\n        arr = []\n        for query in queries:\n            count, sm = 0, 0\n            for i in range(len(nums)):\n                if sm + nums[i] <= query:\n                    sm += nums[i]\n                    count += 1\n            arr.append(count)\n        return arr\n```
['Python', 'Java', 'JavaScript']