首页 > 代码库 > LeetCode "Remove Duplicates from Sorted List"
LeetCode "Remove Duplicates from Sorted List"
The key of this problem is about details especially boundary conditions.
class Solution {public: ListNode *deleteDuplicates(ListNode *head) { if(!head) return NULL; ListNode *p = head; ListNode *p0 = p->next; while(p && p0) { while(p && p0 && p->val == p0->val) { p->next = p0->next; p0 = p0->next; } p = p0; if(p0) p0 = p0->next; } return head; }};
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。