2300. Successful Pairs of Spells and Potions

class Solution:
    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:

        potions.sort()
        def numSuccess(spell):
            
            l, r = 0, len(potions) - 1

            while l <= r:
                mid = (l + r) // 2
                val = potions[mid] * spell

                if val < success:
                    l = mid + 1
                elif val >= success:
                    r = mid - 1

            return len(potions) - l

        return [numSuccess(i) for i in spells]