Skip to content

Commit

Permalink
455. 分发饼干
Browse files Browse the repository at this point in the history
  • Loading branch information
BGMer7 committed Jul 25, 2022
1 parent 891b970 commit 10ef206
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/com/gatsby/_455AssignCookies.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.gatsby;

import java.util.Arrays;

/**
* @ClassName: _455AssignCookies
* @Description:
* @author: Gatsby
* @date: 2022/7/25 13:34
*/

public class _455AssignCookies {
public int findContentChildren(int[] appetite, int[] biscuits) {
Arrays.sort(appetite);
Arrays.sort(appetite);
Arrays.sort(biscuits);
int children = 0;
int a = appetite.length;
int b = biscuits.length;
for (int i = 0, j = 0; i < a && j < b; ++i, ++j) {
while (j < b && biscuits[j] < appetite[i]) ++j;
if (j < b) children++;
}
return children;
}
}


0 comments on commit 10ef206

Please sign in to comment.