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

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0