C++ Solution
Code\n\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) {\n        sort(nums.begin(), nums.end());\n        ve
# Code\n```\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) {\n        sort(nums.begin(), nums.end());\n        vector<int> ans;\n        for(auto x: queries) {\n            int sum = 0, len = 0;\n            for(int i=0; i<nums.size(); i++) {\n                sum += nums[i];\n                if(sum <= x) len = i + 1;\n            }\n            ans.push_back(len);\n        }\n        return ans;\n    }\n};\n```
['C++']