Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 7 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Oct 6, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions problems/0455.分发饼干.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ function findContentChildren(g: number[], s: number[]): number {
### C

```c
///小餅乾先餵飽小胃口的
int cmp(int* a, int* b) {
return *a - *b;
}
Expand All @@ -296,6 +297,33 @@ int findContentChildren(int* g, int gSize, int* s, int sSize){
}
```

```c
///大餅乾先餵飽大胃口的
int cmp(int* a, int* b) {
return *a - *b;
}

int findContentChildren(int* g, int gSize, int* s, int sSize){
if(sSize == 0)
return 0;

//将两个数组排序为升序
qsort(g, gSize, sizeof(int), cmp);
qsort(s, sSize, sizeof(int), cmp);

int count = 0;
int start = sSize - 1;

for(int i = gSize - 1; i >= 0; i--) {
if(start >= 0 && s[start] >= g[i] ) {
start--;
count++;
}
}
return count;
}
```

### Scala

```scala
Expand Down

AltStyle によって変換されたページ (->オリジナル) /