✅✅✅ C++ using upper bound || Very Easy and Simple to Understand solution
Up Vote If you like the solution\n\nTake the prefix sum of the num.\nThen find the upper bound of each query item.\n\n    vector<int> answerQueries(vector<int>&
<b>Up Vote If you like the solution\n\nTake the prefix sum of the num.\nThen find the upper bound of each query item.\n```\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) {\n        vector<int> ans;\n        sort(nums.begin(), nums.end());\n        for(int i = 1; i < nums.size(); ++i){  nums[i] += nums[i-1]; }\n        for(auto q: queries){\n            if(q > nums.back()) ans.push_back(nums.size());\n            else{\n                int n = upper_bound(nums.begin(), nums.end(), q) - nums.begin();\n                ans.push_back(n);\n            }\n        }\n        return ans;\n    }\n```
[]