Skip to content

Commit 2412608

Browse files
authored
83. Remove Duplicates from Sorted List
1 parent 08f14f4 commit 2412608

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//Remove Duplicates from Sorted List
2+
3+
//C++ Solution
4+
5+
class Solution {
6+
public:
7+
ListNode* deleteDuplicates(ListNode* head) {
8+
//if(head == 0|| head->next == 0)return 0;
9+
ListNode*curr = head;
10+
while(curr&&curr->next){
11+
if( curr->val == curr->next->val){
12+
curr->next = curr->next->next;
13+
}
14+
else{
15+
curr = curr->next;
16+
}
17+
}
18+
return head;
19+
}
20+
};

0 commit comments

Comments
 (0)