This commit is contained in:
Electrominch
2022-10-11 01:45:16 +03:00
parent c019e8856c
commit 02afed9c4c
34 changed files with 691 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
namespace _83._Remove_Duplicates_from_Sorted_List;
public class Solution
{
public ListNode? DeleteDuplicates(ListNode? head)
{
ListNode? first = null;
ListNode? current = null;
while (head != null)
{
if (first == null)
first = current = head;
if (head.val == current!.val)
{
head = head.next;
continue;
}
current!.next = head;
current = current.next;
head = head.next;
}
if(current != null)
current.next = null;
return first;
}
}