leetcode

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

0083.cpp (311B)


      1 class Solution {
      2   public:
      3     ListNode *deleteDuplicates(ListNode *head) {
      4         if (!head) return nullptr;
      5         for (ListNode *p = head; p->next;)
      6             if (p->val == p->next->val)
      7                 p->next = p->next->next;
      8             else
      9                 p = p->next;
     10         return head;
     11     }
     12 };