Java | Easy
public int[] answerQueries(int[] a, int[] q) {\n\n        Arrays.sort(a);\n        for(int i = 1; i < a.length; i++){\n            a[i] += a[i-1];\n        }\n 
public int[] answerQueries(int[] a, int[] q) {\n\n        Arrays.sort(a);\n        for(int i = 1; i < a.length; i++){\n            a[i] += a[i-1];\n        }\n        int [] res = new int[q.length];\n        for(int i = 0; i < q.length; i++){\n            int sum = 0;\n            int j = 0;\n            for(j = 0; j < a.length; j++){\n                if(sum + a[j] > q[i]) break;\n            }\n            res[i]=j;\n        }\n        return res;\n    }\n\t\n\t\n\tPlease upvote if its helpful
['Java']