✅C++ || Binary Search || Explanation with Comments
Please Upvote If It Helps\n\n\nclass Solution {\npublic:\n    vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) \n    {\
**Please Upvote If It Helps**\n\n```\nclass Solution {\npublic:\n    vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) \n    {\n        // declare a vector of size spell that will store our ans\n        int n = spells.size();\n        int m = potions.size();\n        vector<int> ans(n,0);\n        \n        // sort the potions fir applying the binary search\n        sort(potions.begin(),potions.end());\n        \n        int i = 0;                    // it will help in storing the ans\n        \n        // start iterating over the spells\n        for(auto& x : spells)\n        {\n            int l = 0;\n            int r = m-1;\n            int mid;\n            \n            // binary search\n            while(l <= r)\n            {\n                mid = (l+r)>>1;\n                \n                // if it gives our need then reduce the window to the left side for cheking more \n                if((long long)x*potions[mid] >= success)\n                    r = mid-1;\n                \n                // if not then check to the right side\n                else\n                    l = mid+1;\n            }\n            ans[i] = m-l;            // storing the answer (total size - not needed size)\n            i++;\n        }\n        return ans;\n    }\n};\n```
['C']