Cpp Solution better than 98% O(nlogn) time complexity
Complexity\n- Time complexity: O(nlogn), Better than 98% Online Cpp Submissions\n\n- Space complexity: Better than 65.60% Online Cpp Submissions\n\n# Code\n\ncl
# Complexity\n- Time complexity: O(nlogn), Better than 98% Online Cpp Submissions\n\n- Space complexity: Better than 65.60% Online Cpp Submissions\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& n, vector<int>& queries) {\n        sort(n.begin(),n.end());\n        vector<int>v;\n        for(int i=1;i<n.size();i++)\n        {\n            n[i]+=n[i-1];\n        }\n       for (int& q: queries)\n            v.push_back(upper_bound(n.begin(), n.end(), q) - n.begin());\n   return v; }\n};\n```
['Array', 'C', 'Sorting', 'Prefix Sum', 'C++']