Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Desolve/55fea85d03d195ae3ff6a2d7e5500524 to your computer and use it in GitHub Desktop.
Save Desolve/55fea85d03d195ae3ff6a2d7e5500524 to your computer and use it in GitHub Desktop.
0083 Remove Duplicates from Sorted List
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode deleteDuplicates(ListNode head) {
ListNode ite = head;
while(ite != null) {
ListNode tmp = ite.next;
while (tmp != null && ite.val == tmp.val) tmp = tmp.next;
ite.next = tmp;
ite = tmp;
}
return head;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment