We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ec5888c commit d59573eCopy full SHA for d59573e
1 file changed
Week04/FindContentChildren.java
@@ -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