LeetCode 83. Remove Duplicates from Sorted List
程序员文章站
2022-07-14 08:40:04
...
83. Remove Duplicates from Sorted List
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
ListNode dummy(-1);
dummy.next = head;
ListNode* walk = &dummy;
ListNode* stop = &dummy;
int val1 = 0xefffffff;
while(walk->next !=NULL){
walk = walk->next;
int val2 = walk->val;
if(val1 !=val2){
stop->next = walk;
stop = walk;
val1 = val2;
}
}
if(stop != walk)
stop->next = walk->next;
return dummy.next;
}
};
推荐阅读
-
【一天一道LeetCode】#26. Remove Duplicates from Sorted Array
-
LeetCode 83. Remove Duplicates from Sorted List
-
83. Remove Duplicates from Sorted List
-
LeetCode 83. Remove Duplicates from Sorted List
-
LeetCode 83. Remove Duplicates from Sorted List ***
-
Leetcode 83. Remove Duplicates from Sorted List
-
Leetcode No.26 Remove Duplicates from Sorted Array(c++实现)
-
26. Remove Duplicates from Sorted Array
-
【LeetCode】80. Remove Duplicates from Sorted Array II (删除排序数组中的重复项 II)-C++实现及详细图解
-
【LeetCode】26. Remove Duplicates from Sorted Array (删除排序数组中的重复项)-C++实现的两种方法