Problem
You get two arrays of positive integers, spells and potions, with the lengths n and m. spells[i] is the strength of spell i. potions[j] is the strength of potion j.
You also get an integer success. A spell and a potion make a successful pair when the product of their strengths is at least success.
Return an array pairs of length n. pairs[i] is the number of potions that make a successful pair with spell i.
Example 1
- Input:
- spells = [4,1,6], potions = [2,5,3,1], success = 12
- Output:
- [2,0,3]
- Explanation:
- Spell 4 gives the products 8, 20, 12 and 4, so two products are at least 12. Spell 6 gives 12, 30, 18 and 6.
Example 2
- Input:
- spells = [2,7], potions = [9], success = 20
- Output:
- [0,1]
- Explanation:
2 * 9 = 18is less than 20.7 * 9 = 63is at least 20.
Example 3
- Input:
- spells = [10], potions = [1,1,1], success = 10
- Output:
- [3]
Constraints
- n == spells.length
- m == potions.length
- 1 <= n, m <= 10^5
- 1 <= spells[i], potions[j] <= 10^5
- 1 <= success <= 10^10
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2300. Successful Pairs of Spells and Potions
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source