C++ | Sorting | Prefix Sum | ~98% Time ~36% Space
\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& v, vector<int>& q) {\n      int n = v.size();\n      sort(v.begin(), v.end());\n      ve
```\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& v, vector<int>& q) {\n      int n = v.size();\n      sort(v.begin(), v.end());\n      vector<int> ans, psum(n, v[0]);\n      for(int i = 1; i < n; i++){\n        psum[i] = psum[i - 1] + v[i]; \n      }\n      for(auto &k: q){\n        ans.emplace_back(upper_bound(psum.begin(), psum.end(), k) - psum.begin());\n      }\n      return ans;\n    }\n};\n```
['C', 'Sorting', 'Prefix Sum', 'C++']