Skip to content

Commit f138da7

Browse files
committed
create csharp/0203-remove-linked-list-elements.cs
1 parent 9014b37 commit f138da7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class Solution
2+
{
3+
public ListNode RemoveElements(ListNode head, int val)
4+
{
5+
ListNode dummy = new ListNode(0, head);
6+
ListNode current = dummy;
7+
8+
while (current.next is not null)
9+
{
10+
if (current.next.val == val)
11+
{
12+
current.next = current.next.next;
13+
}
14+
else
15+
{
16+
current = current.next;
17+
}
18+
}
19+
return dummy.next;
20+
}
21+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy