package leet;
public class RemoveDuplicatesFromSortedList {
public ListNode deleteDuplicates(ListNode head) {
if (head == null) {
return null;
}
ListNode temp = head;
while (temp != null && temp.next != null) {
if (temp.val == temp.next.val) {
temp.next = temp.next.next;
} else {
temp = temp.next;
}
}
return head;
}
}
Remove Duplicates from Sorted List
最新推荐文章于 2023-01-13 08:10:00 发布