Skip to content

Commit 6d31949

Browse files
committedOct 14, 2015
"Remove Duplicates from Sorted List II": lint code
1 parent 7fef3b8 commit 6d31949

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed
 

‎src/82.c

+4-12
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@ struct ListNode* deleteDuplicates(struct ListNode* head) {
1919
while (p && q) {
2020
if (p->val == q->val) {
2121
pre->next = q->next;
22-
p = p->next;
23-
q = q->next;
2422
}
25-
else {
26-
if (pre->next == q) {
27-
p = p->next;
28-
q = q->next;
29-
}
30-
else {
31-
pre = pre->next;
32-
p = p->next;
33-
q = q->next;
34-
}
23+
else if (pre->next != q) {
24+
pre = pre->next;
3525
}
26+
p = p->next;
27+
q = q->next;
3628
}
3729

3830
struct ListNode *new_head = dummy->next;

0 commit comments

Comments
 (0)
Please sign in to comment.