package leetcode;

/**
 * https://leetcode.com/problems/assign-cookies/
 */
public class Problem455 {
    public int findContentChildren(int[] g, int[] s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem455 prob = new Problem455();
        System.out.println(prob.findContentChildren(new int[]{1, 2, 3}, new int[]{1, 1})); // 1
        System.out.println(prob.findContentChildren(new int[]{1, 2}, new int[]{1, 2, 3})); // 2
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -188,38 +188,77 @@
     
-// TODO%0A        return
+Arrays.sort(g);%0A        Arrays.sort(s);%0A%0A        int result =
  0;%0A    
 %7D%0A%0A 
@@ -257,291 +257,321 @@
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem455 prob = new Problem455();%0A        System.out.println(prob.findContentChildren(new int%5B%5D%7B1, 2, 3%7D, new int%5B%5D%7B1, 1%7D)); // 1%0A        System.out.println(prob.findContentChildren(new int%5B%5D%7B1, 2%7D, new int%5B%5D%7B1, 2, 3%7D)); // 2
+int size = 0;%0A        for (int greed = 0; greed %3C g.length; greed++) %7B%0A            for (; size %3C s.length; size++) %7B%0A                if (s%5Bsize%5D %3E= g%5Bgreed%5D) %7B%0A                    result++;%0A                    size++;%0A                    break;%0A                %7D%0A            %7D%0A        %7D%0A        return result;
 %0A   

Solve problem 455