C++||Easy&Simple||Sorting||Greedy🔥🔥|| TC-O(n^2)
\n\n# Complexity\n- Time complexity: O(n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \
\n\n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxCnt=0,currCnt=0;\n    int helper(vector<int>&nums,int target){\n       int cnt=0;\n       int low=0,high=nums.size()-1;\n       while(low<=high && target!=0){\n           if(target-nums[low]>=0){\n               target-=nums[low];\n               low++;\n           }\n           else if(target-nums[high]>=0){\n                target-=nums[high];\n                high--;\n           }\n           else return cnt;\n           cnt++;\n       }\n       return cnt;\n    }\n    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) {\n        sort(nums.begin(),nums.end());\n        vector<int>ans(queries.size());\n        for(int i=0;i<queries.size();i++){\n            ans[i]=helper(nums,queries[i]);\n        }\n        return ans;\n    }\n};\n```
['C++']