Created
June 14, 2014 16:56
-
-
Save honux77/a06d6e20de7781e227f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/