455. 分发饼干

题目链接:https://leetcode.cn/problems/assign-cookies/description/

Java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Solution {
public int findContentChildren(int[] g, int[] s) {
Arrays.sort(g);
Arrays.sort(s);
int sum = 0;
int i = 0, j = 0;
while( i < s.length && j < g.length) {
if (s[i] < g[j] ) {
i++;
} else {
sum ++;
j++;
i++;
}
}
return sum;
}
}

455. 分发饼干
https://pisces34.github.io/2025/04/24/leetcode/455/
发布于
2025年4月24日
许可协议