TC->O((m+n)logn)||SC->O(logn)
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[] nums, int[] queries) {\n     int n=nums.length;\n     int m=queries.length;\n     int ans[]=new int[m];\n     Arrays.sort(nums);\n\n     for(int i=1;i<n;i++){\n         nums[i]=nums[i-1]+nums[i];\n\n     }\n     for(int i=0;i<m;i++){\n         ans[i]=binarysearch(nums,queries[i]);\n\n     }\n     return ans;\n        \n    }\n    private int binarysearch(int nums[],int sum){\n        int l=0,h=nums.length-1;\n        int len=0;\n        while(l<=h){\n            int mid=l+(h-l)/2;\n            if(nums[mid]<=sum)\n            {\n                len=Math.max(len,mid+1);\n                l=mid+1;\n            }\n            else{\n                h=mid-1;\n            }\n\n        }\n        return len;\n\n    }\n}\n```
['Binary Search', 'Sorting', 'Prefix Sum', 'Java']