Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit107309e

Browse files
Merge pull requestneetcode-gh#3203 from RakeshTirumala/main
Create 2300-successful-pairs-of-spells-and-potions.java
2 parentsbba9e31 +38a358f commit107309e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
classSolution {
2+
publicint[]successfulPairs(
3+
int[]spells,int[]potions,longsuccess) {
4+
int []res =newint[spells.length];
5+
Arrays.sort(potions);
6+
for(inti=0;i<spells.length;i++){
7+
intspell =spells[i];
8+
intl =0,r =potions.length-1;
9+
while(l<=r){
10+
intm =l+(r-l)/2;
11+
if((long)spell*potions[m]>=success)r=m-1;
12+
elsel=m+1;
13+
}
14+
res[i] = (l<potions.length)?potions.length-l:0;
15+
}
16+
returnres;
17+
}
18+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp