We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Description
Given a sorted linked list, delete all duplicates such that each element appear only once.
Example 1:
Input: 1->1->2 Output: 1->2
Example 2:
Input: 1->1->2->3->3 Output: 1->2->3
解题思路:这题比较简单,一层遍历,如果下一个值相同就直接将其指向下下一个值,否则头结点下移一位
C解题:
struct ListNode* deleteDuplicates(struct ListNode* head){ struct ListNode* orign_head1 = head; while (head) { if(!head->next) break; if (head->val == head->next->val) { head->next = head->next->next; }else{ head = head->next; } } return orign_head1; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
Given a sorted linked list, delete all duplicates such that each element appear only once.
Example 1:
Example 2:
解题思路:这题比较简单,一层遍历,如果下一个值相同就直接将其指向下下一个值,否则头结点下移一位
C解题:
The text was updated successfully, but these errors were encountered: