83.Remove Duplicates from Sorted List(E)
https://leetcode.com/problems/remove-duplicates-from-sorted-list/
1.Description(Easy)
2.Code
public static ListNode deleteDuplicates(ListNode head) {
if(head==null ||head.next==null){
return head;
}
ListNode current=head;
while(current.next!=null){
if(current.val==current.next.val){
current.next=current.next.next;
}
else{
current=current.next;
}
}
return head;
}Last updated
