From 9cea1567fe338ec4842276c4e27e9d4933893bd3 Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Mon, 25 Dec 2023 09:35:23 +0800 Subject: [PATCH] =?UTF-8?q?Update0455.=E5=88=86=E5=8F=91=E9=A5=BC=E5=B9=B2?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0C#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0455.分发饼干.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/problems/0455.分发饼干.md b/problems/0455.分发饼干.md index c9c1a852..778adc94 100644 --- a/problems/0455.分发饼干.md +++ b/problems/0455.分发饼干.md @@ -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; + } +} +```