✅  Java | Sorting + Binary Search Approach
\n// Approach 2: Sorting  + Binary Search (Lower Bound)\n\n// Time complexity: O((m + n) log m)\n// Space complexity: O(log m)\n\npublic int[] successfulPairs(i
```\n// Approach 2: Sorting  + Binary Search (Lower Bound)\n\n// Time complexity: O((m + n) log m)\n// Space complexity: O(log m)\n\npublic int[] successfulPairs(int[] spells, int[] potions, long success) {\n\tint n = spells.length;\n\tint m = potions.length;\n\tint[] pairs = new int[n];\n\n\tArrays.sort(potions); // m log m\n\n\tfor (int i = 0; i < n; i++) { // n log m\n\t\tint left = 0, right = m;\n\n\t\twhile (left < right) {\n\t\t\tint mid = left + (right - left) / 2;\n\n\t\t\tif ((long) spells[i] * (long) potions[mid] >= success)\n\t\t\t\tright = mid;\n\t\t\telse\n\t\t\t\tleft = mid + 1;\n\t\t}\n\n\t\tpairs[i] = m - left;\n\t}\n\n\treturn pairs;\n}\n```\n\n**Please upvote if you find this solution useful. Happy Coding!**
['Sorting', 'Binary Tree', 'Java']