JAVA Easy Solution 🔥 Beginner Friendly 🔥
Please UPVOTE if helps.\n\n# Complexity\n- Time complexity: O(n) \n\n# Code\n\nclass Solution {\n    public int[] answerQueries(int[] array, int[] queries) {\n 
# Please UPVOTE if helps.\n\n# Complexity\n- Time complexity: $$O(n)$$ \n\n# Code\n```\nclass Solution {\n    public int[] answerQueries(int[] array, int[] queries) {\n        Arrays.sort(array);\n        int[] result = new int[queries.length];\n        for (int i = 0; i < queries.length; i++) {\n            int sum = 0;\n            int j = 0;\n            for (j = 0; j < array.length; j++) {\n                if (sum + array[j] > queries[i]) {\n                    result[i] = j;\n                    break;\n                }\n                sum += array[j];\n            }\n            if (j == array.length) result[i] = array.length;\n        }\n        return result;\n    }\n}\n```
['Java']