标签:因此 跳过 code solution 通过 lang while problems ++
链接:https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/
思路
Code
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
ListNode *cur = head;
//cur!=nullptr:1->1->2,cur->next!=nullptr:1->1->2->3->3
while (cur != nullptr && cur->next != nullptr) {
if (cur->val == cur->next->val) {
cur->next = cur->next->next;
}
else {
cur = cur->next;
}
}
return head;
}
};
复杂度分析
标签:因此 跳过 code solution 通过 lang while problems ++
原文地址:https://www.cnblogs.com/bky-hbq/p/13172027.html