Skip to content

Commit 875122b

Browse files
authored
Update Remove Duplicates From Sorted Lists.java
1 parent 1c0e419 commit 875122b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Easy/Remove Duplicates From Sorted Lists.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
* public class ListNode {
44
* int val;
55
* ListNode next;
6-
* ListNode(int x) { val = x; }
6+
* ListNode() {}
7+
* ListNode(int val) { this.val = val; }
8+
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
79
* }
810
*/
911
class Solution {
1012
public ListNode deleteDuplicates(ListNode head) {
1113
ListNode curr = head;
1214
while (curr != null) {
13-
if (curr.next != null && curr.val == curr.next.val) {
15+
while (curr.next != null && curr.next.val == curr.val) {
1416
curr.next = curr.next.next;
1517
}
16-
else {
17-
curr = curr.next;
18-
}
18+
curr = curr.next;
1919
}
2020
return head;
2121
}

0 commit comments

Comments
 (0)