Skip to content

Commit 605243e

Browse files
committed
Solved leetcode 2300
1 parent a6c3b63 commit 605243e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: 2300/2300.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
3+
res = []
4+
n = len(potions)
5+
potions = sorted(potions)
6+
for spell in spells:
7+
l = 0
8+
r = n - 1
9+
count = 0
10+
while(l <= r):
11+
mid = (l + r)//2
12+
prod = spell * potions[mid]
13+
if(prod >= success):
14+
count = max(n - mid, count)
15+
r = mid - 1
16+
else:
17+
l = mid + 1
18+
res.append(count)
19+
20+
return res

0 commit comments

Comments
 (0)