From 752cfda89351cc2d54897a6309a181f197cc6c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=9C=E5=B0=8F=E8=B7=AF=E4=B8=83=E8=91=89?= <20304773@qq.com> Date: Tue, 31 May 2022 23:46:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=880027.=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=85=83=E7=B4=A0.md=EF=BC=89=EF=BC=9A=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20C#=20=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0027.移除元素.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/problems/0027.移除元素.md b/problems/0027.移除元素.md index 3a93ac88..5e7742ee 100644 --- a/problems/0027.移除元素.md +++ b/problems/0027.移除元素.md @@ -329,5 +329,20 @@ int removeElement(int* nums, int numsSize, int val){ } ``` +C#: +```csharp +public class Solution { + public int RemoveElement(int[] nums, int val) { + int slow = 0; + for (int fast = 0; fast < nums.Length; fast++) { + if (val != nums[fast]) { + nums[slow++] = nums[fast]; + } + } + return slow; + } +} +``` + -----------------------