leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2300.cpp (433B)


      1 class Solution {
      2   public:
      3     vector<int> successfulPairs(vector<int> &spells, vector<int> &potions, long long success) {
      4         sort(potions.begin(), potions.end());
      5 
      6         vector<int> res;
      7         for (int i = 0; i < spells.size(); i++) {
      8             auto it = lower_bound(potions.begin(), potions.end(), ceil(success / (double)spells[i]));
      9             res.push_back(potions.end() - it);
     10         }
     11         return res;
     12     }
     13 };