Skip to content

Commit 865ae45

Browse files
committed
solultion: solved #27 in c#
1 parent 282f034 commit 865ae45

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

csharp/27.remove-element.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* @lc app=leetcode id=27 lang=csharp
3+
*
4+
* [27] Remove Element
5+
*/
6+
7+
// @lc code=start
8+
public class Solution
9+
{
10+
public int RemoveElement(int[] nums, int val)
11+
{
12+
int i = 0;
13+
for (int j = 0; j < nums.Length; j++)
14+
{
15+
if (nums[j] != val)
16+
{
17+
nums[i] = nums[j];
18+
i++;
19+
}
20+
}
21+
return i;
22+
}
23+
24+
}
25+
26+
// @lc code=end
27+

0 commit comments

Comments
 (0)