mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update0455.分发饼干,添加C#
This commit is contained in:
@ -378,6 +378,28 @@ object Solution {
|
||||
}
|
||||
}
|
||||
```
|
||||
### C#
|
||||
```csharp
|
||||
public class Solution
|
||||
{
|
||||
public int FindContentChildren(int[] g, int[] s)
|
||||
{
|
||||
Array.Sort(g);
|
||||
Array.Sort(s);
|
||||
int index = s.Length - 1;
|
||||
int res = 0;
|
||||
for (int i = g.Length - 1; i >=0; i--)
|
||||
{
|
||||
if(index >=0 && s[index]>=g[i])
|
||||
{
|
||||
res++;
|
||||
index--;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
|
Reference in New Issue
Block a user