Skip to content

Commit 38cf8c3

Browse files
authored
Create Remove Duplictes from Sorted List.java
1 parent e52d25e commit 38cf8c3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//83. Remove Duplicates from Sorted List
2+
class Solution {
3+
public ListNode deleteDuplicates(ListNode head) {
4+
ListNode curr = head;
5+
6+
while (curr != null) {
7+
while (curr.next != null && curr.val == curr.next.val)
8+
curr.next = curr.next.next;
9+
curr = curr.next;
10+
}
11+
12+
return head;
13+
}
14+
}

0 commit comments

Comments
 (0)