Skip to content

Instantly share code, notes, and snippets.

@honux77
Created June 14, 2014 16:56
Show Gist options
  • Select an option

  • Save honux77/a06d6e20de7781e227f0 to your computer and use it in GitHub Desktop.

Select an option

Save honux77/a06d6e20de7781e227f0 to your computer and use it in GitHub Desktop.
/**
* https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Solution {
public ListNode deleteDuplicates(ListNode head) {
ListNode t = head;
while(t != null && t.next != null) {
if(t.val == t.next.val)
t.next = t.next.next;
else
t = t.next;
}
return head;
}
}
@honux77
Copy link
Copy Markdown
Author

honux77 commented Jun 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment