JS | Binary search | Runtime: 83.33%
\nvar successfulPairs = function(spells, potions, success) {\n\tlet res = [];\n\tpotions.sort((a, b) => a - b);\n\tfor (let i = 0; i < spells.length; i++) {\n\t
```\nvar successfulPairs = function(spells, potions, success) {\n\tlet res = [];\n\tpotions.sort((a, b) => a - b);\n\tfor (let i = 0; i < spells.length; i++) {\n\t\tlet h = potions.length-1, l = 0, mid;\n\t\twhile (l <= h) {\n\t\t\tmid = ~~(l + (h-l)/2);\n\t\t\tif (spells[i] * potions[mid] >= success) h = mid-1;\n\t\t\telse l = mid+1;\n\t\t}\n\t\tres[i] = potions.length-1 - h;\n\t}\n\treturn res;\n};\n```
['Binary Tree', 'JavaScript']