1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// @Title: 分发饼干 (Assign Cookies)
// @Author: 15816537946@163.com
// @Date: 2020-06-25 07:15:36
// @Runtime: 40 ms
// @Memory: 6 MB
func findContentChildren(g []int, s []int) int {
	sort.Ints(g)
	sort.Ints(s)

	var gi,si,count int

	for gi< len(g) &&  si< len(s) {
		if s[si] >=g[gi] {
			gi++
			si++
			count++
		} else {
			si++
		}
	}

	return count
    
}