Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions 82/82.shadowing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
```cpp
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
ListNode dummy(0, head);
ListNode* prev = &dummy;
ListNode* curr = head;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以下のコメントをご参照ください。
hemispherium/LeetCode_Arai60#10 (comment)


while (curr != nullptr) {
if (curr->next != nullptr && curr->val == curr->next->val) {
int dup_val = curr->val;

while (curr != nullptr && curr->val == dup_val) {
curr = curr->next;
}

prev->next = curr;
} else {
prev = curr;
curr = curr->next;
}
}

return dummy.next;
}
};


```