C++ || PrefixSum || Upper_bound || Simple Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nMaximum subsequence from the array is obtained by applying prefix sum.\nAnd number of e
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMaximum subsequence from the array is obtained by applying prefix sum.\nAnd number of element is calculated by subtracting first index from the upper bound of the query from the nums.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    TC : O(NlogN)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    SC : O(N)\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> answerQueries(vector<int>& nums, vector<int>& q) {\n        sort(nums.begin(),nums.end());\n        for(int i=1;i<nums.size();i++)nums[i]+=nums[i-1];\n        for(int i =0;i<q.size();i++){\n            q[i]=upper_bound(nums.begin(),nums.end(),q[i])-nums.begin();\n        }\n        return q;\n    }\n};\n```
['C++']