mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
添加(0027.移除元素.md):增加 C# 版本
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
-----------------------
|
||||
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
|
||||
|
Reference in New Issue
Block a user