Longest subsequence with limited sum
\n# Code\n\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) {\n        sort(nums.begin(),nums.end());\n       
\n# Code\n```\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) {\n        sort(nums.begin(),nums.end());\n        for(int i=1;i<nums.size();i++)\n        nums[i]+=nums[i-1];\n        vector<int>ans;\n        for(auto it:queries){\n            int ind=upper_bound(nums.begin(),nums.end(),it)-nums.begin();\n            ans.push_back(ind);\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'Sorting', 'Prefix Sum', 'C++']