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
给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。
输入: 1->1->2 输出: 1->2
输入: 1->1->2->3->3 输出: 1->2->3
/** * Definition for singly-linked list. * function ListNode(val) { * this.val = val; * this.next = null; * } */ /** * @param {ListNode} head * @return {ListNode} */ var deleteDuplicates = function(head) { let start = NaN; let ans = new ListNode(); let next = head let result = ans while( next ){ if( start != next.val ){ start = next.val; result.next = new ListNode(); result.next.val = start; result = result.next; } next = next.next; } return ans.next };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目描述
给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。
示例 1:
示例 2:
The text was updated successfully, but these errors were encountered: