You are given two arrays: spells, where each element represents the power of a spell, and potions, where each value represents the strength of a potion.
For any spell–potion pair, if the product of their values is greater than or equal to a given threshold called success, the pair is marked as successful.
Your task is to build an output array result, where result[i] tells how many potions can form a successful pair with the i-th spell.
Input: spells = [4, 2, 6] potions = [3, 1, 5, 7] success = 15
Output: [2, 0, 3]
Explanation:
Spell 4 pairs successfully with potions giving products: [12, 4, 20, 28] → 3 valid Spell 2 → [6, 2, 10, 14] → 1 valid Spell 6 → [18, 6, 30, 42] → 3 valid
Input: spells = [10, 1] potions = [2, 20, 3] success = 25
Output: [2, 0]
Accepted:
Submission: