✅C++ || ✅Simple || ✅Easy to Understand
\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) \n    {\n        int n = nums.size();\n        int m = queri
```\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) \n    {\n        int n = nums.size();\n        int m = queries.size();\n        \n        sort(nums.begin(),nums.end());\n        int sum = 0;\n        vector<int> pre_sum;\n        \n        for(int i=0;i<n;i++)\n        {\n            sum += nums[i];\n            pre_sum.push_back(sum);           // storing prefix sum\n        }\n        \n        vector<int> ans(m,0);\n        for(int i=0;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(pre_sum[j] <= queries[i]) ans[i] = j+1;          // wherever we got the max subsequence sum for i just update that\n                else break;\n            }\n        }\n        return ans;\n    }\n};\n```
['Prefix Sum']