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

Commit72f877e

Browse files
authored
Create Fruits Into Baskets II.java
1 parent7e86b13 commit72f877e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎Easy/Fruits Into Baskets II.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
classSolution {
2+
publicintnumOfUnplacedFruits(int[]fruits,int[]baskets) {
3+
intcount =0;
4+
for (intfruit :fruits) {
5+
intidx = -1;
6+
for (inti =0;i <baskets.length;i++) {
7+
if (baskets[i] >=fruit) {
8+
idx =i;
9+
break;
10+
}
11+
}
12+
if (idx == -1) {
13+
count++;
14+
}else {
15+
baskets[idx] = -1;
16+
}
17+
}
18+
returncount;
19+
}
20+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp