1
# Runtime: 3070 ms (Top 29.46%) | Memory: 37.4 MB (Top 40.00%)
2
class Solution:
3
def successfulPairs(
4
self, spells: List[int], potions: List[int], success: int
5
) -> List[int]:
6
result = self.function(spells, potions, success)
7
return result
8

9
def function(self, arr1, arr2, success):
10
n2 = len(arr2)
11
arr2.sort() # Sorting Enables Us To Do Binary Search
12
ans = []
13
for i in arr1:
14
val = math.ceil(
15
success / i
16
) # Finding the Value Of Portion With Least Strength So That It Can Be Greater Than Success
17
idx = bisect.bisect_left(
18
arr2, val
19
) # Finding The Left Most Index So That The Value Can Be Inserted
20
res = (
21
n2 - idx + 1
22
) # Calculating the remaining numbers after finding the suitable index
23
ans.append(res - 1)
24
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0