Swift | Binary Search
Binary Search (accepted answer)\n\nclass Solution {\n    func successfulPairs(_ spells: [Int], _ potions: [Int], _ success: Int) -> [Int] {\n        let potions
**Binary Search (accepted answer)**\n```\nclass Solution {\n    func successfulPairs(_ spells: [Int], _ potions: [Int], _ success: Int) -> [Int] {\n        let potions = potions.sorted()\n        \n        return spells.map { spell in\n            var (left, right) = (0, potions.count)\n            while left < right {\n                let mid = (left+right)/2\n                (left, right) = spell * potions[mid] >= success ? (left, mid) : (mid+1, right)\n            }\n            return potions.count - left\n        }\n    }\n}\n```
['Swift']