```
public class Solution {
public int findContentChildren(int[] g, int[] s) {
if (g == null || g.length == 0 || s == null || s.length == 0) {
return 0;
}
Arrays.sort(g);
Arrays.sort(s);
int p1 = 0;
int p2 = 0;
int content = 0;
while (p1 < g.length && p2 < s.length) {
if (g[p1] <= s[p2]) {
p1++;
p2++;
content++;
} else {
p2++;
}
}
return content;
}
}
```