1class Solution {2public int[] successfulPairs(int[] spells, int[] potions, long success) {3int n = spells.length;4int m = potions.length;5int[] pairs = new int[n];6Arrays.sort(potions);7for (int i = 0; i < n; i++) {8int spell = spells[i];9int left = 0;10int right = m - 1;11while (left <= right) {12int mid = left + (right - left) / 2;13long product = (long) spell * potions[mid];14if (product >= success) {15right = mid - 1;16} else {17left = mid + 1;18}19}20pairs[i] = m - left;21}22return pairs;23}24}