Python Binary Search EASY TO UNDERSTAND SOLUTION
\n# Code\n\nclass Solution:\n    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:\n        n = len(spells)\n        
\n# Code\n```\nclass Solution:\n    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:\n        n = len(spells)\n        m = len(potions)\n        pairs = [0] * n\n\n        # Info from question\n            # spells[i] = strength of i\n            # potion[j] = strength of j\n            # product of strength is at least success\n            # pairs[i] is number of potions that will form a successful pair with ith spell\n\n        # Algo\n            # Use binary search to get the mid potion\n            # while low <= high\n            # - if mid >= success, increment by (m-mid) since mid->m would all be greaterthan\n            # if it is, increment pairs[i]\n\n        # Sort potions before the order does not matter\n        potions.sort()\n\n        # Iterate over spells\n        for i in range(n):\n            # Get low and high variables for binary search\n            low = 0\n            high = m\n            # While low is less than high, keep looping\n            while low < high:\n                # get mid\n                mid = (low + high) // 2\n                # Check if product is higher than success\n                if spells[i] * potions[mid] >= success:\n                    pairs[i] += (high-mid)\n                    high = mid\n                else:\n                    # We are at the bottom of the list\n                    if low == mid:\n                        break\n                    # Everything before mid would not pass success, so we move up\n                    low = mid\n        return pairs\n```
['Array', 'Two Pointers', 'Binary Search', 'Sorting', 'Python3']