[C++] || Sorting || Take Smaller numbers first
Sort the queries array and nums array. \n* For any query i , if the length of subsequnce is len , then for any query > i , length will be atleast len. \n\nclass
* Sort the `queries array` and `nums array`. \n* For any query `i` , if the length of subsequnce is `len` , then for any `query > i` , length will be atleast `len`. \n```\nclass Solution {\npublic:\n    vector<int> ans ;\n    vector<int> answerQueries(vector<int>& nums , vector<int>& Q) {\n        vector<array<int,2>> temp ;\n        ans.resize(Q.size(),0) ;\n        \n        for(int i = 0 ; i < Q.size() ; ++i ) temp.push_back({Q[i],i}) ;\n        \n        sort(begin(temp),end(temp)) ;\n        sort(begin(nums),end(nums)) ;\n        \n        int sum = 0 , j = 0;\n        \n        //This Loop Operates in O(N) Time\n        for(auto &x : temp){\n            int bound = x[0] ;\n            int i = x[1] ;\n            \n            //This Loop Will only Loop Once in its lifetime\n            while(j < nums.size()){\n                if(sum + nums[j] > bound) break ;\n                sum += nums[j++] ;\n            }\n            ans[i] = j ;\n        }\n        \n        return ans ;\n    }\n};\n```
['C']