Successful Pairs of Spells and Potions
You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the i^th spell and potions[j] represents the strength of the j^th potion.
You are also given an integer success. A spell and potion pair is considered successful if the product of their strengths is at least success.
Return an integer array pairs of length n where pairs[i] is the number of potions that will form a successful pair with the i^th spell.
Example 1
Input
spells = [5,1,3], potions = [1,2,3,4,5], success = 7Output
[4,0,3]For spells 5, 1, and 3, there are respectively 4, 0, and 3 potions whose product with the spell is at least 7.
Example 2
Input
spells = [3,1,2], potions = [8,5,8], success = 16Output
[2,0,2]For spells 3, 1, and 2, there are respectively 2, 0, and 2 potions whose product with the spell is at least 16.
Constraints
- n == spells.length
- m == potions.length
- 1 <= n, m <= 10^5
- 1 <= spells[i], potions[i] <= 10^5
- 1 <= success <= 10^10