leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0082.cpp (481B)


0 class Solution {
1 public:
2 ListNode *deleteDuplicates(ListNode *head) {
3 ListNode top(-200, head);
5 for (ListNode *p = &top, *c = head; c && c->next; c = c->next) {
6 if (c->val == c->next->val) {
7 while (c && c->next && c->val == c->next->val)
8 c = c->next;
9 p->next = c->next;
10 if (!c) break;
11 } else
12 p = p->next;
13 }
15 return top.next;
16 }
17 };