leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2300.cpp (433B)
0 class Solution { 1 public: 2 vector<int> successfulPairs(vector<int> &spells, vector<int> &potions, long long success) { 3 sort(potions.begin(), potions.end()); 4 5 vector<int> res; 6 for (int i = 0; i < spells.size(); i++) { 7 auto it = lower_bound(potions.begin(), potions.end(), ceil(success / (double)spells[i])); 8 res.push_back(potions.end() - it); 9 } 10 return res; 11 } 12 };