Skip to content

Commit d59573e

Browse files
committed
提交分饼干作业
1 parent ec5888c commit d59573e

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Week04/FindContentChildren.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Arrays;
2+
3+
public class FindContentChildren {
4+
5+
public int findContentChildren(int[] g, int[] s) {
6+
if ((null == g || g.length == 0) || (null == s || s.length == 0)) {
7+
return 0;
8+
}
9+
Arrays.sort(g);
10+
Arrays.sort(s);
11+
int count = 0;
12+
int i = 0;
13+
int j = 0;
14+
while (i < g.length && j < s.length)
15+
{
16+
if(s[j] >= g[i])
17+
{
18+
count++;
19+
i++;
20+
}
21+
j++;
22+
}
23+
return count;
24+
}
25+
}

0 commit comments

Comments
 (0)