C++ | O((N+M)*LogM TC Solution | Binary Search on solution space
\nclass Solution {\npublic:\n    vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {\n        sort(potions.begin(), poti
```\nclass Solution {\npublic:\n    vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {\n        sort(potions.begin(), potions.end());\n        int n = spells.size(), m = potions.size();\n        vector<int> output;\n        for(int i = 0; i<n; i++) {\n            if (spells[i]*1ll*potions[m-1] < success) {\n                output.push_back(0);\n                continue;\n            } \n            \n            if (spells[i]*1ll*potions[0] >= success) {\n                output.push_back(m);\n                continue;\n            }\n            // find min index such that spells[i]*potions[idx] >= success\n            int lo = -1; // min impossible value;\n            int hi = m-1; // max possible value\n            \n            while(hi - lo > 1) {\n                int mid = lo + (hi-lo)/2;\n                if (spells[i]*1ll*potions[mid] >= success) {\n                    hi = mid;\n                } else {\n                    lo = mid;\n                }\n            }\n            output.push_back(m-(lo+1));\n        }\n        return output;\n    }\n};\n```
[]