BINARY SEARCH || C++ || PLEASE UPVOTE
Intuition\nCan be done in binary search.\n\n# Approach\nStarting with the sorting of potions  , After that getting the element till which (spells[i]*potions[mid
# Intuition\nCan be done in binary search.\n\n# Approach\nStarting with the sorting of potions  , After that getting the element till which (spells[i]*potions[mid]) is greater than success and store those elements in pairs[i].\nThe submission shall be taken care of for long long type casting.\n\n# Complexity\n- Time complexity:\nO(nlogm)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {\n        int n=spells.size(),m=potions.size();\n       \n       \n       sort(potions.begin(),potions.end());\n       vector<int> pairs(n);\n      for(int i=0;i<n;i++){\n          int c=0,l=0,r=m-1;\n        while(l<=r){\n            \n            int mid=l+(r-l)/2;\n            if((long long)spells[i]*(long long)potions[mid]>=success){\n                r=mid-1;\n                \n            }\n            else{\n                l=mid+1;\n            }\n        }\n        pairs[i]=m-1-r;\n        }\n\n        \n        return pairs;\n    }\n};\n```
['C++']