✅C++ || ✅Simple || ✅Easy to Understand
\nclass Solution {\npublic:\n     vector<int>v;\n     vector<int> answerQueries(vector<int>& nums, vector<int>& queries) \n     {\n        vector<int>ans(querie
```\nclass Solution {\npublic:\n     vector<int>v;\n     vector<int> answerQueries(vector<int>& nums, vector<int>& queries) \n     {\n        vector<int>ans(queries.size(),0);\n        v=nums;\n\n        sort(v.begin(),v.end());     // binary serach\n        for(int i=1;i<v.size();i++)  //[4 5 2 1]  -> [4 9 11 12]   sorted\n        {\n           v[i]+=v[i-1];\t\n        }\n        for(int i=0;i<queries.size();i++)\n        {\n          ans[i] = getans(queries[i])+1;\t\n        }       \n        return ans;\n     }\n     int getans(int limited_sum)     // [1 2 4 5]  -> [1 3 7 12]  sorted\n     {\n        int start = 0;\n        int end = v.size()-1;\n        int ans=-1;\n        while(start<=end)\n        {\n            int mid = (start+end)/2;\n\n            if(v[mid]<=limited_sum)\n            {\n                ans=mid;\n                start=mid+1;\n            }\n            else\n            {\n                end=mid-1;\n            }\n        }\n        return ans;\n     }\n     //10        1 1 2 2 1 2 5 6 7 2 3   -->\n};\n```
['C', 'C++']