$ cat ./coding/2300-successful-pairs-of-spells-and-potions.md
[Coding]
2300. Successful Pairs of Spells and Potions
────────────────────────────────────────────────────────────
2300. Successful Pairs of Spells and Potions
class Solution:
def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
def search(arr, target):
left = 0
right = len(arr)
while left < right:
mid = left + (right - left)//2
if arr[mid] >= target:
right = mid
else:
left = mid + 1
return left
potions.sort()
res = []
m = len(potions)
for spell in spells:
i = search(potions, success/spell)
res.append(m - i)
return res
--tags#Binary Search
$ ls ./coding/ | grep -v 2300-successful-pairs-of-spells-and-potions