Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public int findContentChildren(int[] g, int[] s) {
- Arrays.sort(s);
- Arrays.sort(g);
- int res = 0;
- for (int i = 0; i < s.length && res < g.length; i++) {
- if (s[i] >= g[res]) res++;
- }
- return res;
- }
- }
- /*
- [1,2,3]
- [1,1]
- [10,9,8,7]
- [5,6,7,8]
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement