Skip to content

#2300 - Successful Pairs of Spells and Potions

MediumBinary Search
Open on LeetCode

Given arrays spells and potions, and an integer success, a pair (i, j) is successful if spells[i] * potions[j] >= success. Return an array where each element is the number of successful pairs for that spell.

InputOutput
spells = [5,1,3], potions = [1,2,3,4,5], success = 7[4,0,3]
spells = [3,1,2], potions = [8,5,8], success = 16[2,0,2]

Released under the MIT License.