Skip to content

Commit 8a918a7

Browse files
2300: Successful Pairs of Spells and Potions
1 parent 6b07fe9 commit 8a918a7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# https://leetcode.com/problems/successful-pairs-of-spells-and-potions/editorial/
2+
# T: O((n + m)logm) where n is the number of spells and m is the number of potions
3+
# S: O(m) where m is the number of potions
4+
5+
class Solution:
6+
def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
7+
potions.sort()
8+
return [len(potions) - bisect_left(potions, (success + x - 1) // x) for x in spells]

0 commit comments

Comments
 (0)