Easy Java Solution || Prefix Sum
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] answerQueries(int[] arr, int[] q) {\n        int n = arr.length;\n        Arrays.sort(arr);\n\n        for(int i=1; i<n; i++){\n            arr[i] += arr[i-1];\n        }\n    \n        int ans[] = new int[q.length];\n\n        for(int i=0; i<q.length; i++){\n            int st = 0;\n            int end = n-1;\n            int count = 0;\n            while(st<=end){\n                int mid = st+(end-st)/2;\n                if(arr[mid]>q[i]) end = mid-1;\n                else{\n                    count = mid+1;\n                    st = mid+1;\n                }\n            }\n            ans[i] = count;\n        }\n        return ans;\n    }\n}\n```
['Java']