Problem 54 of 75

Successful Pairs of Spells and Potions

MediumNot solved yetInterview me on this
Before you code · which pattern fits?

The problem

Given arrays spells and potions and an integer success, a pair (spell, potion) is successful if spell × potion ≥ success. For each spell, return how many potions form a successful pair with it.

(spells=[5,1,3], potions=[1,2,3,4,5], success=7) → [4,0,3]

Your solution runs against 2 unit tests, including edge and large-value cases.

Loading...

Test console · 2 unit tests

Submit your code to run it against all 2 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.

Hint

Reference solution

Video explanation

Successful Pairs of Spells and Potions, explainedNeetCodeIO