Skip to content

Commit 2a0435f

Browse files
authored
Create Remove Duplicates from Sorted List.java
1 parent 219bc7e commit 2a0435f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public ListNode deleteDuplicates(ListNode head) {
2+
ListNode temp = head;
3+
while (temp!=null) {
4+
while (temp.next!=null && temp.val == temp.next.val) {
5+
temp.next = temp.next.next;
6+
}
7+
temp = temp.next;
8+
9+
return head;
10+
}

0 commit comments

Comments
 (0)