您的位置:首页 > 其它

455. [LeetCode]Assign Cookies

2016-12-05 09:35 351 查看
[超简单贪心]

public class Solution {
public int findContentChildren(int[] g, int[] s) {
int size_s = s.length;
int size_g = g.length;
// 先排序
Arrays.sort(s);
Arrays.sort(g);
int i=0;
int j=0;
int count=0;
for(i=0;i<size_s;i++){
int s_temp = s[i];
for(j=count;j<size_g;j++){
int g_temp = g[j];
if(s_temp>=g_temp){
count++;
break;
}
}
}
return count;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode