Python 3 | Math, Binary Search | Explanation
Explanation\n- The order of potions doesn\'t matter, we just need to find out how many potion can form a successful pair with the current spell\n\t- Thus, we ca
### Explanation\n- The order of `potions` doesn\'t matter, we just need to find out how many potion can form a *successful* pair with the current *spell*\n\t- Thus, we can sort `potions` to make a faster binary search\n- We can\'t use spell to multiply each potion, it takes a long time `O(mn)`; \n\t- Instead, we can use `success` to divided by the current *spell*, which is a `O(1)` operation\n- If `success % spell == 0`, then we want to include `success // spell`\n\t- Thus, we will use a `bisect_left`\n- Otherwise, we don\'t want to include  `success // spell`\n\t- Thus, we will use a `bisect_right`\n- `n - idx` is the number of *successful* potions with the current *spell*\n- Time: `O(nlgm), n = len(spells), m = len(potions)`\n### Implementation\n```\nclass Solution:\n    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:\n        potions.sort()\n        ans, n = [], len(potions)\n        for spell in spells:\n            val = success // spell\n            if success % spell == 0:\n                idx = bisect.bisect_left(potions, val)\n            else:    \n                idx = bisect.bisect_right(potions, val)\n            ans.append(n - idx)\n        return ans\n```
['Math', 'Binary Search', 'Python', 'Python3']