Update0455.分发饼干,添加C#
This commit is contained in:
parent
3bd387df7c
commit
9cea1567fe
|
|
@ -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">
|
<p align="center">
|
||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue